根据这个问题Access Denied for MYSQL ERROR 1045 我应该能够使用
以安全模式启动MySQLsudo mysqld_safe --skip-grant-tables
但这只是将以下行记录到STDOUT:
151116 17:46:46 mysqld_safe Logging to '/usr/local/var/mysql/MacBook-Pro.local.err'.
151116 17:46:46 mysqld_safe Starting mysqld daemon with databases from /usr/local/var/mysql
151116 17:46:46 mysqld_safe mysqld from pid file /usr/local/var/mysql/MacBook-Pro.local.pid ended
并将我返回到命令行。 引用的错误日志在此处输出相同的最后2行。当我尝试连接到MySQL时,我得到:
mysql -uroot -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
答案 0 :(得分:1)
在mac上遇到完全相同的问题。我可以通过以下步骤重置root密码。
mysqld --skip-grant-tables # this will run mysql
mysql -u root
mysql> FLUSH PRIVILEDGES;
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'newpassword';
注意:运行'sudo mysqld_safe --skip-grant-tables'时,似乎更新版本的mysql有错误。