Reset root password for mysql on mysql 5.5

First kill the running mysql service:

kill `cat /var/run/mysqld/mysqld.pid`

Now, start mysql without permission tables:

mysqld_safe --skip-grant-tables &

Now start mysql as root without password:

mysql -u root

Now, within mysql import password tables and change the password:

mysql> FLUSH PRIVILEGES;
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('MyNewPass');
mysql> FLUSH PRIVILEGES;

Now, kill the running mysql service and restart the service:

service mysql restart

You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.