On mac os, please follow below steps:
Stop MySQL
$ sudo /usr/local/mysql/support-files/mysql.server stop Start it in safe mode:
$ sudo mysqld_safe --skip-grant-tables (above line is the whole command)
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
mysql> UPDATE mysql.user SET Password=PASSWORD('password') WHERE User='root'; Start MySQL
sudo /usr/local/mysql/support-files/mysql.server start your new password is 'password'.