PostNuke

Flexible Content Management System

News

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/hostname.pid`




2. Restart MySQL in safe mode:




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




3. Connect to MySQL:




/usr/bin/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:




quit




8. Stop mysql from command line with:




/etc/init.d/mysql stop




9. Restart mysql from command line with:




/etc/init.d/mysql start
40045