How to reset MySQL root password through SSH on CentOS Linux server?

How to reset MySQL root password through SSH on CentOS Linux server?

You can reset your MySQL root password if you forget that or you are having any issue related to that.

1. First of all, log into the server as root using SSH.

2. Now, stop MySQL service:
# /etc/init.d/mysql stop
3. Start MySQL server without password:
# mysqld_safe --skip-grant-tables &
4. Connect to MySQL:
# mysql -u root
5. Setup new MySQL root password:
mysql> use mysql;
mysql> update user set password=PASSWORD("newpassword") where User='root';
mysql> flush privileges;
mysql> quit
6. Stop MySQL Server:
# /etc/init.d/mysql stop
7. Stop and start the MySQL service and test it:
# /etc/init.d/mysql stop
# /etc/init.d/mysql start
# mysql -u root -p
Author
bhawanisingh
Views
2,499
First release
Last update
Rating
0.00 star(s) 0 ratings
Top