Mac解决 Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)问题
我在mac电脑安装mysql,发现连接失败:
MacBook-Pro:etc chenxianchong$ mysql -uroot -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
我的解决方法:
原因很简单,
找不到/tmp/mysql.sock这个文件,解决步骤如下:
1、修改my.cnf文件,一般是在/etc/my.cnf目录中
对你指定的目录赋予777权限
sudo chmod 777 /etc/mysqlsock/mysql.sock
重启mysql
sudo /usr/local/mysql/support-files/mysql.server restart