change root password on mysql

sudo service mysql stop
sudo mysqld_safe --skip-grant-tables --skip-syslog --skip-networking

then run mysql in a new terminal

mysql -u root

and run the following query, after changing the password

UPDATE mysql.user SET Password=PASSWORD('password') WHERE User='root';
FLUSH PRIVILEGES;

quit the mysql safe mode and start mysql service by

mysqladmin shutdown
sudo service mysql start

http://stackoverflow.com/questions/10895163/how-to-find-out-the-mysql-root-password