Check if MySQL is running. (display all sockets with TCP protocol, show program name for them)

netstat -tap | grep mysql


Stop MySQL:

sudo stop mysql

or

sudo /etc/init.d/mysql stop


Start MySQL server so that everyone could connect without a password and with all privileges (+ prevent remote clients from connecting for security reasons):

sudo mysqld --skip-grant-tables --skip-networking


In another shell tab connect to MySQL without password

mysql


Update passwords in the MySQL:

mysql> update mysql.user set password = password('your_new_password') where user = 'root';
mysql> flush privileges;


Stop the MySQL server:

sudo mysqladmin shutdown


Start normally:

sudo start mysql


Connect normally:

mysql -u root -p

Read more: http://feeds.dzone.com/~r/dzone/snippets/~3/Jn1--7Pghu4/13267