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

Posted 2BiTT

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mac ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock&相关的知识,希望对你有一定的参考价值。

好久不用mysql,今天突然想用的时候,

mysql -uroot -p

直接报了下面的错误

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

mac可以在设置里面启动mysql,设置里面启动mysql的时候提示没有/usr/local/mysql/data的权限,

给予权限

sudo chown -R mysql:mysql  /usr/local/mysql

发现还是没用,但是发现mysql当时是配置了链接

qiweijieMacBook-Pro:~ qiweijie$ ll /usr/local/mysql

lrwxr-xr-x  1 _mysql  _mysql  27  2 26  2016 /usr/local/mysql -> mysql-5.7.11-osx10.9-x86_64

虽然给了mysql权限,还是只是给到了链接的权限,没有得到真正的mysql目录的权限

qiweijieMacBook-Pro:~ qiweijie$ ll /usr/local/mysql-5.7.11-osx10.9-x86_64/

total 48
...
drwxr-x---  16 qiweijie  staff    544 10  7 12:18 data
....

sudo chown -R mysql:mysql  /usr/local/mysql-5.7.11-osx10.9-x86_64/

这样就好了

 

以上是关于mac ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock&的主要内容,如果未能解决你的问题,请参考以下文章

Mac mySql ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/my

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

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

mac使用brew安装mysql报RROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp

ERROR 2002 (HY000): Can’t connect to local MySQL

mysql客户连接时报ERROR 2002 (HY000)