Recover MySQL password in FreeBSD and nix

This is an reminder, and saves time google’ing for the way.

Sometimes we get the question from a customer to check something in there database, noone knew there even was a root password for the database. This is a quick way to change the PW.

In the /etc/rc.conf
mysql_args=”–skip-grant-tables –skip-networking”

And restart the MySQL server. now you can login with mysql -u root -p

Change the PW:
use mysql;
UPDATE USER SET Password=PASSWORD(‘yournewpassword’) WHERE USER=’root’;
Now remove the arguments again from the rc.conf and restart. Voillia.

For linux et start the server like this:
mysqld –user=mysql –skip-grant-tables –skip-networking &

Gr gr! :)

Leave a Reply

Your email address will not be published. Required fields are marked *