Archive for April, 2012

Reset MySQL root password

Posted in BASH, MySQL, Snippets on April 25, 2012 by anzuthechosen

Haven’t posted much lately so I figured I’d post some snippets of useful commands for general system administration.  One of the most frustrating things for me is forgetting my root MySQL password >_<  Here’s how to reset the root MySQL password from command line in linux :

First, stop mysqld using the following command:

   /etc/init.d/mysqld stop

OR (depending on your system)

   service mysqld stop

Then, start mysqld again, but like this…

   mysqld_safe –skip-grant-tables

Then login to mysql as root, it won’t ask for a password:

   mysql –user=root mysql

Once your at the mysql prompt, enter the following commands:

   update user set Password=PASSWORD(‘new-password‘) where user=’root’;

   flush privileges;

Then, just stop mysqld again and restart it like normal.  Your new password will be new-password !