Recover Lost Mysql Password
So you've lost the root user password for mysql. here's how you can reset it when looged onto the console as root.
1. Stop mysql
service mysqld stop
2. Restart MySQL in safe mode:
/usr/bin/safe_mysqld --skip-grant-tables&
(Note the above works in mysql 3, for mysql 4 it changed slightly, see below)
/usr/bin/mysqld_safe --skip-grant-tables&
3. Connect to the Mysql server
/usr/bin/mysql
4. Use the mysql database:
> use mysql;
5. Run the update command (replace "
" with your new password. Note it is enclose by ' inside the brackets)
> 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:
service mysqld stop
9. Restart mysql from command line with:
service mysqld start
other Linux Related Tips...