Stop the MySQL service
# /etc/init.d/mysqld stop
Add skip-grant-tables
# edit /etc/my.cnf and add skip-grant-tables under [mysqld] section
Start the MySQL service
# /etc/init.d/mysqld start
Log into the MySQL server without any password
# mysql
Reset the password for ‘root’ user
mysql> use mysql
mysql> UPDATE user SET password=PASSWORD('password.new') where user='root';
Flush privileges
mysql> flush privileges;
Stop the MySQL service
# /etc/init.d/mysqld stop
Edit my.cnf and remove skip-grant-tables
Start the MySQL service
# /etc/init.d/mysqld start
Log-in with the new password
# mysql -u root -p password.new
# /etc/init.d/mysqld stop
Add skip-grant-tables
# edit /etc/my.cnf and add skip-grant-tables under [mysqld] section
Start the MySQL service
# /etc/init.d/mysqld start
Log into the MySQL server without any password
# mysql
Reset the password for ‘root’ user
mysql> use mysql
mysql> UPDATE user SET password=PASSWORD('password.new') where user='root';
Flush privileges
mysql> flush privileges;
Stop the MySQL service
# /etc/init.d/mysqld stop
Edit my.cnf and remove skip-grant-tables
Start the MySQL service
# /etc/init.d/mysqld start
Log-in with the new password
# mysql -u root -p password.new
Comments