mysql.sock is not created OSX

2019-02-17 05:42发布

I run mysql on OSX, now when I restart my computer it does not create the mysql.sock, meaning that all my connections gives me a error 2002.

anyone knows how to prevent this?

5条回答
何必那么认真
2楼-- · 2019-02-17 05:57

I had this same issue on Snow Leopard, the socket spawns in the wrong location for some reason on OS X.

To get the socket spawning in the correct location: create a new file "my.cnf" in /etc with the following lines:

[mysqld]
socket=/var/mysql/mysql.sock

[client]
socket=/var/mysql/mysql.sock

and restart mysqld: sudo /usr/local/mysql/bin/mysqld_safe

This will force the MySQL socket file to spawn in the proper location, and everything should work normally. Good luck!

查看更多
Viruses.
3楼-- · 2019-02-17 06:08

I recommend to execute

sudo find / -name "mysql.sock"

to be sure the file is not anywhere.

In my cas I used the command mysql with variant socket in this way

mysql --socket=/var/lib/mysql/mysql.sock
查看更多
再贱就再见
4楼-- · 2019-02-17 06:08

I've been having trouble in restarting MySQL on a box running Sierra. Every time that I tried to connect after restarting my machine, I would lose the ability to connect to my MySQL instance. Based on this post, I determined that there was, indeed, no my.cnf file in my environment. I followed DashRantic's instructions to force a build of a socket file. It appears to have resolved the problem.

查看更多
三岁会撩人
5楼-- · 2019-02-17 06:15

I use Mac OS 10.12 Sierra, I meet the same mysql question. I can find mysql.sock in my file system.

Resolve question method:

1 remove my.cnf

sudo rm -rf /etc/my.cnf

restart your mysql servers

brew services restart mysql

or

sudo launchctl unload -F /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist

sudo launchctl load -F /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist

you can check it

sudo lost -i tcp:3306

enter image description here

mysql is running ok.

enter image description here

查看更多
够拽才男人
6楼-- · 2019-02-17 06:20

I had that problem on a Linux box once, and I found that the directory (/var/run/mysqld) was not writable by the user mysql runs as. I would check that if I were you.

查看更多
登录 后发表回答