Changing mySQL root user password

Posted: February 20th, 2008 | Author: steve | Filed under: linux, web dev |

It’s a pain in the nuts if you forget your mySQL root password. Here’s an easy way to reset it:

1) Stop any running mySQL deamons

2) Open a text editor and create a new file with the follownig line in it:

SET PASSWORD FOR ‘root’@'localhost’ = PASSWORD(’<your new password>’);

3)  Run the mySQL deamon and use the –init-file flag to force mySQL to process the change password command:

mysqld_safe –init-file=<the file from step 2> &

You might need to sudo that mysqld_safe command.



Leave a Reply