Posts Tagged ‘MySQL’

There are times when you may have to recover the MySQL root password because it was either forgotten or misplaced. The steps you need are:

1. Stop MySQL
[root@idoumo tmp]# service mysqld stop
Stopping MySQL: [ OK ]

2. Start MySQL in Safe mode with the safe_mysqld command and tell it not to read the grant tables with all the MySQL database passwords.

[root@idoumo tmp]# safe_mysqld –skip-grant-tables &
[root@idoumo tmp]# Starting mysqld daemon with databases from /var/lib/mysql

3. Use the mysqladmin command to reset the root password. In this case, you are setting it to ack33nsaltf1sh.

[root@idoumo tmp]# mysqladmin -u root flush-privileges password “ack33nsaltf1sh”

4. Restart MySQL normally.
[root@idoumo tmp]# service mysqld restart
Stopping MySQL: 040517 09:39:38 mysqld ended [ OK ]
Starting MySQL: [ OK ]
[1]+ Done safe_mysqld –skip-grant-tables

The MySQL root user will now be able to manage MySQL using this new password.