In this blog, I will show you how to reset the root password for MySQL Server. On the Linux server, I have added a user name for myself and I allowed myself to be able to sudo. To add myself as a new user, type:
useradd chuong
passwd chuong
usermod -aG sudo,adm chuong
First, open two SSH connections to the MySQL Server.
SSH chuong@WebServer
sudo su
In the first SSH connection windows, type:
service mysql stop
sudo mysqld_safe –skip-grant-tables –skip-syslog –skip-networking
In the second SSH connection windows, type:
mysql –u root
UPDATE mysql.user SET Password=PASSWORD(‘MYPASSWORD’) WHERE User=’root';
FLUSH PRIVILEGES;
Now Quit MySQL Safe mode and start the MySQL server:
mysqladmin shutdown
sudo service mysql start
Now we are able to access MySQL.
Conclusion:
In this blog post, I have shown you how to reset the root password for MySQL Server.