Mac下运行mysql出错ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock

因为Mac好久没有关过机,非常的卡,然后我就关了一下机

再打开之后一运行mysql -uroot -p
就报错

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

Navicat Premium也连接不到mysql

Can't connect to MySQL server on '127.0.0.1' (61 "Connection refused")

然后我就很绝望,在网上找了好多方法,也试了好多方法
疯狂的找mysql.sock文件,也没有找到

我以为是因为brew安装mysql的锅,想着要卸掉mysql,在官网重新下载

还好。。。最后发现是我没有启动mysql服务
终端下输入:

mysql.server start
Starting MySQL
 SUCCESS! 

因为之前我更改过密码

mysql -u root -p

输入密码就可以了,Navicat Premium也连接上mysql了

参考博客:https://www.cnblogs.com/zhjsll/p/5702950.html

你可能感兴趣的:(Mac的程序安装,sql)