首页 > 代码库 > 长久不用的mysql报错ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

长久不用的mysql报错ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

mac上安装过mysql:

技术分享

然而,尝试连接时报错:

$ mysql -u root -pEnter password: ERROR 2002 (HY000): Cant connect to local MySQL server through socket /tmp/mysql.sock (2)

尝试去查看mysql.socket文件,发现没有。。

$ which mysql/usr/local/bin/mysql

然后试试重启mysql:

$ mysql.server startStarting MySQL. SUCCESS! 

哎 ,说明咱的mysql还能用的嘛,其实内心很担心是不是装了zsh导致的不能启动mysql。。

$ mysql -u root -pEnter password: Welcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 4Server version: 5.7.17 Homebrew

哈哈 这么简单就启动了 可以查看各种内容了,还是要多动多练才可以

$ mysql.server start$ mysql.server restart$ mysql.server stop$ mysql.server status$ mysql -u root -p$ sudo mysql    #以root权限登录

 

长久不用的mysql报错ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)