Change MySQL root Password in OS X or Linux

If you have forgot the MySQL root password, can't remember or want to break in... you can reset the mysql database password from the command line in either OS X or Linux as long as you know the root user password of the following you are on

Stop MySQL

$ sudo /usr/local/mysql/support-files/mysql.server stop

Start it in safe mode

$ sudo mysqld_safe --skip-grant-tables

This will be an ongoing command until the process is finished so open another shell/terminal window, log in without a password

$ mysql -u root
UPDATE mysql.user SET authentication_string=PASSWORD('password') WHERE User='root';

Change the lowercase password to what you want – with single quotes.

$ FLUSH PRIVILEGES;
\q

Start MySQL

$ sudo /usr/local/mysql/support-files/mysql.server start
0.00 avg. rating (0% score) - 0 votes