stop the MySQL server (two ways)
- open the monitor,kill the mysql(for me, it didn't work).
- open the system preference - mysql, click the bottom "stop"
reset the password
sudo /usr/local/mysql/bin/mysqld_safe --skip-grant-tables
open another terminal
$sudo /usr/local/mysql/bin/mysql -u root
input the system password
$ UPDATE mysql.user SET authentication_string=PASSWORD('新密码') WHERE User='root';
$FLUSH PRIVILEGES;
$\q
ref
http://devlu.me/2016/01/18/Mac%E4%B8%8B%E9%87%8D%E7%BD%AEMysql%E7%9A%84root%E5%AF%86%E7%A0%81/
https://dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html( the manual documentation seems complicated but more detailed.
网友评论