mac 第一次安装mysql 5.7.12 不知道root 密码的解决办法

搞了2个晚上,这个必须记录一下

1.    先从系统偏好设置里 把 mysql 停掉

2.    打开mac 命令行工具,sudo su 以管理员身份运行命令

3.    cd /usr/local/mysql/bin     (mysql的安装目录)

4.    ./mysqld_safe --skip-grant-tables &

5.    mysql -p

6.    mysql> update mysql.user set authentication_string=password('123qwe'where user='root' and Host = 'localhost';

7.    flush privileges;

做完所有以上步骤再从workbench基本输2次密码就可以连上了

第5步很重要,因为网上很多人写的第5步是通过workbench 重置密码,我自己尝试无效,不知道是不是版本的问题

原文地址:https://www.cnblogs.com/janey/p/5503390.html