愚蠢的人类忘记了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.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容