kenzabukuro on Twittter

How to reset MySQL root password from command line

Because you will mess this up and need to reset the password from the command line. SSH into your server and:

    su -
    sudo service mysqld stop
    sudo mysqld_safe --skip-grant-tables

That's stopping MySQL on Red Hat family. If you have something else, just go lie in the road and die.

Then open a new terminal:

    mysql -u root
    UPDATE mysql.user SET Password=PASSWORD('password') WHERE User='root';
    FLUSH PRIVILEGES;
    \q
    sudo service mysqld start

Yay! Now go screw up something else.