Forgetting passwords isn’t generally a good idea. It does happen, though, and if it happens to your MySQL server, this is the process you need to follow in order to recover it.
First of all, you need to stop the running MySQL server. You need to be root on your system, then:
# /etc/init.d/mysql stop
Now, we need to make a text file called an init file. The contents of this file will be executed in a moment when we restart the MySQL server in a special way. So, create a new text file in your home folder and place this in the file:
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpassword');
Obviously, substitute in your desired password (leaving the quotes intact). Save the file as passwordinit.
Now, we need to start the MySQL server with this init file. Still as root on the system, run:
# mysqld_safe --init-file=~/passwordinit &
As soon as you press Enter, the password has been changed. Now I recommend restarting the MySQL server in the normal way, as follows:
# /etc/init.d/mysql restart
And that’s it. Be more careful next time.



fsdaily.com wrote:
Story added…
This story has been submitted to fsdaily.com! If you think this story should be read by the free software community, come vote it up and discuss it here:
http://www.fsdaily.com/EndUser/Reset_your_MySQL_root_password…
# Posted on 11-Mar-08 at 9:12 am
links for 2008-03-12 « B-link List wrote:
[…] FOSSwire » Reset your MySQL root password Forgetting passwords isn’t generally a good idea. It does happen, though, and if it happens to your MySQL server, this is the process you need to follow in order to recover it. (tags: mysql password recovery sql) […]
# Posted on 12-Mar-08 at 12:28 am
Reset your root MySQL password « Now I Remember wrote:
[…] Originally published on FOSSwire […]
# Posted on 08-Apr-08 at 12:45 am
InTiLinuX wrote:
Resettare la password di root di Mysql…
In caso di smarrimento della password di root di Mysql è possibile seguire questi semplici passi per resettare la password e inserirne una nuova.
Prima di tutto, è necessario arrestare il server MySQL in esecuzione:
# sudo /etc/init.d/mysql stop
…
# Posted on 14-Apr-08 at 3:24 pm
Create a mirror of a website with Wget « Now I Remember wrote:
[…] Originally published on FOSSwire […]
# Posted on 23-Apr-08 at 9:38 pm