MySQL root user hack

In case you have forgotten your root password for MySQL database, you can change it by first killing all mysql processes with:

killall mysql or /etc/init.d/mysql stop (for Debian users)

Now you have to start mysql again with this command:

mysqld --skip-grant-tables &

Then you can change your MySQL root user password with:

mysqladmin -u root flush-privileges password 'newpassword'

And now you have to stop mysql again with:

killall mysqld

After this you can start your MySQL normaly with your usual command like:

/etc/initd/mysql start

That’s it, simple but realy usefull trick…

Leave a Reply

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