It was very difficult for me to fix this problem on MAC Sierra, 10.12.6, MySql version 5.7.17
The following steps helped me:
Open a terminal window, use the command below to stop mysql if it is already running.
sudo / usr / local / mysql / support-files / mysql.server stop
Start MySQL with this command:
sudo / usr / local / mysql / bin / mysqld_safe --skip-grant-tables
Open a new terminal window / tab:
root sudo / usr / local / mysql / bin / mysql -u
This will open the mysql prompt. Run the following command at the mysql prompt one by one:
use mysql; UPDATE user SET authentication_string = PASSWORD('my_new_password'), password_expired = 'N' WHERE User = 'root'; FLUSH PRIVILEGES; EXIT
Now first stop the MySql server, then start it using the commands below
sudo / usr / local / mysql / support-files / mysql.server stop
sudo / usr / local / mysql / support-files / mysql.server start
Hope this solves your problem.
source share