You must reset the password! steps for mac osx (tested and working) and ubuntu
Stop MySQL
$ sudo /usr/local/mysql/support-files/mysql.server stop
Run it in safe mode:
$ sudo mysqld_safe --skip-grant-tables
(above line is the whole command)
This will be the current command until the process completes, 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'; mysql> flush privileges; mysql> exit;
For the version of Mysql (mysql Ver 14.14 Distrib. 5.7.19) -
Try the syntax as the mysql user table has been updated a bit.
sudo mysqld_safe --skip-grant-tables mysql> UPDATE mysql.user SET authentication_string = PASSWORD('password') WHERE User = 'root' AND Host = 'localhost'; mysql> FLUSH PRIVILEGES; sudo /usr/local/mysql/support-files/mysql.server start
your new password is "password".
source share