Reset - Mysql - password-ubuntu

Reset MySQL root password in ubuntu

  1. edit config file by
   sudo gedit /etc/mysql/mysql.conf.d/mysqld.cnf 
  1. in [mysqld] section, below ‘skip-external-locking’ add line
   skip-grant-tables
  1. restart MySQL
sudo systemctl restart mysql
  1. enter mysql
   mysql -u root -p
  1. switch to mysql database
   use mysql;
  1. change root password to ‘passwd’:
UPDATE mysql.user SET authentication_string=password('passwd') WHERE User='root' AND Host ='localhost';
  1. update plugin field:
UPDATE user SET plugin="mysql_native_password";

(plugin field is used to authenticate user, if it is empty, server will use built-in method)

  1. flush privileges;
    quit;
  2. revert back the config file /etc/mysql/mysql.conf.d/mysqld.cnf by remove or comment out the line has been added.

  3. start mysql again and login with new passwd

    sudo systemctl start mysql

    K8s installation on Centos

    k8s installation Centos7