Forgot your MySQL root password? Don’t worry I’ll tell you the simplest way to reset MySQL root password. This guide will work for Linux and Windows OS as well.
So without wasting any valuable time lets start with the:
Steps to reset MySQL Root Password:
Step 1: Stop MySQL service: You can do this using three methods:
/etc/init.d/mysql stop service mysql stop systemctl stop mysql Stopping MySQL database server: mysqld.
Step 2: Start MySQL with –skip-grant-tables option:
mysqld_safe --skip-grant-tables [1] 5988 Starting mysqld daemon with databases from /var/lib/mysql mysqld_safe[6025]: started
Step 3: Login to MySQL server without password simply execute:
mysql -u root Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 to server version: 5.5.15-Debian_1-log Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql>
Step 4: Set new password for root user.
use mysql; SET PASSWORD FOR 'root'@'localhost' = PASSWORD('MyNewPass'); flush privileges;
Then change the 'root'@'localhost'
account password. Replace the password with the password that you want to use. To change the password for a root
account with a different host name part, modify the instructions to use that host name.
You have successfully reset your MySQL root password, you should now be able to connect to the MySQL server as root
using the new password. Stop the server and restart it normally.
Step 5: Simply restart the mysql and use new password for login.
/etc/init.d/mysql restart or service mysql restart
Now login with your new root password:
mysql -uroot -p password
Now you should be successfully able to login to MySQL using new password, comment below in case you face any difficulty while you reset MySQL root password.