最近启动mysql总是会报错Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
最近本人的mac,不管是使用命令brew services start mysql
还是在 /usr/local/Cellar/mysql@5.7/5.7.27_1 目录下执行 ./support-files/mysql.server stop 都会报错Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
1、第一步查看/tmp/mysql.sock文件是否存在,发现/tmp目录下只有一个mysql.sock.lock文件,于是执行命令:
cp mysql.sock.lock mysql.sock
2、再次启动mysql,会报错/usr/local/var/mysql/xxxxxdemacbook-pro-2.local.pid is not finded,于是新建一个空的文件xxxxxdemacbook-pro-2.local.pid,并修改权限 chown -Rf _mysql:admin xxxxxdemacbook-pro-2.local.pid
3、不管使用那种方式启动mysql都可以成功