My mysql version is MYSQL V5.7.9. For older versions, please Use:
UPDATE mysql.user SET Password=PASSWORD('新密码') WHERE User='root';
Mac OS X - Reset MySQL Root Password
Too many passwords to remember? ? Have you forgotten the root password of MySQL on Mac OS? You can reset the new password by following 4 steps:
1. Stop mysql server.
Usually in 'System Preferences' > ; MySQL > 'Stop MySQL Server'
2. Open the terminal and enter:
sudo /usr/local/mysql/bin/mysqld_safe --skip-grant-tables
3. Open another new terminal and enter:
sudo /usr/local/mysql/bin/mysql -u root UPDATE mysql.user SET authentication_string=PASSWORD('你的新密码') WHERE User='root'; FLUSH PRIVILEGES; exit
4. Restart MySQL .
Okay, this is complete
Recommended learning: "mysql video tutorial"