Flexible Content Management System


Recover lost MySQL root password mini-HowTo

Contributed by on Nov 28, 2001 - 02:23 PM

1. Kill the mysqld that may be running (not with -9):

kill `cat /var/lib/mysql/`

2. Restart MySQL in safe mode:

/usr/bin/safe_mysqld --skip-grant-tables&

3. Connect to MySQL:


4. Use the mysql database:

use mysql;

5. Run the update command putting your new password where the ....'s are. Yes this is all one command:

update user set password = password('.......') where user = 'root' and host='localhost';

6. Flush the privileges so everything will take:

flush privileges;

7. Then quit mysql:


8. Stop mysql from command line with:

/etc/init.d/mysql stop

9. Restart mysql from command line with:

/etc/init.d/mysql start