How to reset the Mysql root password
How to reset the Mysql root password
Introduction
There might arise a situation where you need to reset the root password for your MySQL database. It can be because you forgot your password or need to change it for security reasons.
Prerequisite
- Server root login credentials.
Follow the Steps to reset,
Step1 :
Login to the account as SSH or use sudo commands as super user.
Step2:
Stop the Mysql server using,
Service mysqld stop
Step3:
Restart the machine with the –skip-grant-tables option.
Mysqld_safe –skip-grant-tables &
Note: & - it will run the command in the background and allow you to type the following commands.
Step4:
Login Mysql
Mysql
Step5:
At the mysql prompt > do the following command to replace the new Password
UPDATE mysql.user SET Password=PASSWORD(‘typenewpassword’);
Step6:
In mysql prompt> type
FLUSH PRIVILIGES; exit;
Step 7:
Stop the MySQL server and it will be promoted to enter the new MySQL root password
mysqladmin –u root –p shutdown
Step 8:
Start the mysql server normally
service mysql start
Login with a new password to continue in the Database system