Thursday, April 10, 2014

How to Reset the Root Password in MySql Database

Run the following commands separately to change/reset your 'root' user password in MySql database.

Some Info:

There is a database called 'mysql' in MySql which is the default database. It is where Users such as 'root' are stored.
In this script, it is assumed that your new password is 'MyNewPassword'. Hence, replace that with what ever you want your password to be.

UPDATE mysql.user 
SET Password=PASSWORD('MyNewPassword') 
WHERE User='root';

FLUSH PRIVILEGES;

More info can be found here.