愚蠢的人类忘记了mysql root的密码

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.

你可能感兴趣的:(愚蠢的人类忘记了mysql root的密码)