Monday, November 03, 2008

Resetting MySql "root" password

Well, if you run as many servers as I do then chances are that you have run into problems with passwords. This tip helps you with resetting MySql root password incase you have forgotten it - (For Linux)

# service mysqld stop (replace mysqld with whatever you call your MySql deamon)

After MySql deamon shutd down execute

# ./mysqld_safe --skip-grant-tables & (most probably this would have to be executed from your /usr/bin directory)

Password skipped!

Now, you will be able to login to your MySql as root with no password.

# ./mysql -uroot mysql

Once in the MySQL command prompt reset your root password

mysql> UPDATE user SET password=PASSWORD("new_pasword") WHERE user="root";
mysql> FLUSH PRIVILEGES;


Now logout by issuing

mysql> exit

And try logging-in with your new set root password

# ./mysql -uroot -pnew_password mysql

No comments: