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

版权声明:本文为博主编写文章,未经博主允许转载,转载请注明出处。 https://blog.csdn.net/u012373815/article/details/82188361

亲测有效

电脑经过一番波折终于回到我的手中,然后美滋滋的打开电脑,准备打开数据库看看数据,发现连不上数据库了。报错

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

好吧,很明显是mysql.sock文件找不到了,这个文件以前在/tmp 下现在没有了,那么怎么办呢?重启一下mysql 服务就会自己生成吧。

重点

我的mysql 是 很早以前用 homebrew 安装的,所以启动就

cd /usr/local/Cellar/mysql/5.7.19
sudo ./support-files/mysql.server start

启动后发现tmp 下就有了一个mysql.sock ,再连接数据库。ok 连接成功

小提示:

去查看mysql 的error 文件 /usr/local/var/mysql/abel-MacBook-Pro.local.err。
发现错误提示 说

The error means mysqld does not have the access rights to the directory

然后我想这个数据库我用好久了怎么可能是没有权限。就不管了,当然我直接mysql.server start 重启mysql 的时候也会报错

The server quit without updating PID file (/usr/local/mysql/data/abel-MacBook-Pro.pid)

猜你喜欢

转载自blog.csdn.net/u012373815/article/details/82188361