https://stackoverflow.com/questions/6474775/setting-the-mysql-root-user-password-on-os-x
Stop the mysqld server. Mac OSX: System Preferences > MySQL > Stop MySQL Server Linux (From Terminal): sudo systemctl stop mysqld.service
Start the server in safe mode with privilege bypass From Terminal: sudo /usr/local/mysql/bin/mysqld_safe --skip-grant-tables
In a new terminal window: sudo /usr/local/mysql/bin/mysql -u root
This will open the mysql command line. From here enter:
UPDATE mysql.user SET authentication_string=PASSWORD('NewPassword') WHERE User='root'; FLUSH PRIVILEGES; quit
Stop the mysqld server again and restart it in normal mode.
Mac OSX (From Terminal): sudo /usr/local/mysql/support-files/mysql.server restart Linux Terminal: sudo systemctl restart mysqld