By default, MySQL server will be installed with root account and password is blank. Have you ever forgotten the root password on one of your MySQL servers? If you have set the password for root and forget it, then you will need to reset the root password for MySQL. To reset your mysql password just follow these instructions and we assume that you already have a small amount of knowledge on MySQL.
This article assumes you have at least basic knowledge of linux, know how to use the shell, and most importantly, you host your site on your own VPS. The reset password MySQL is quite simple. I will show you through the step by step reset root password MySQL server.
Reset Root Password MySQL Server
Step 1. First thing to do is stop MySQL.
### CentOS 6 ### service mysqld stop ### CentOS 7 ### systemctl stop mysqld
Step 2. Next we need to start MySQL in safe mode with the –skip-grant-tables option so that it will not prompt for password.
mysqld_safe --skip-grant-tables &
Step 3. Start the mysql client process using this command with root account and blank password.
mysql -u root
Step 4. Change password for root account.
mysql> use mysql; mysql> update user set password=PASSWORD("NEW-ROOT-PASSWORD") where #User='root'; mysql> flush privileges; mysql> quit
Step 5. Restart MySQL.
Once complete, you can restart MySQL is installed by running the below command:
### CentOS 6 ### service mysqld restart ### CentOS 7 ### systemctl restart mysqld
Congratulation’s! You have successfully reset password MySQL. Thanks for using this tutorial for reset root password MySQL on Linux system. For additional help or useful information, we recommend you to check the official MySQL web site
You Might Also Like: How To Backup and Restore MySQL Database Using Command Line