mysql.sock is not created OSX
Asked Answered
A

5

7

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?

Aborning answered 31/1, 2011 at 2:11 Comment(4)
Did MySQL actually start? If it's starting, it would create the socket automatically.Peon
what does your mysql error log say?Benia
Did you ever solve this problem?Kemper
Yes, a solution that's worked for others (myself included) is posted, would be much obliged if you could mark the correct solution.Kemper
K
21

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!

Kemper answered 31/1, 2011 at 4:4 Comment(5)
This question is duplicated dozens of times yet yours is the first answer that actually helped me. It deserves more upvotes.Hammer
where is the /etc file? I'm sorry if it's s dumb question but idk what that is!Stiffnecked
etc is a directory, not a file. It's located under the root ("/") directory (hence "/etc").Kemper
One additional problem I ran into was that the user that mysql runs as did not have permission to edit /var/mysql/mysql.sock (I think because I created it using sudo), so I had to chmod it before things would work. Actually, MySQL wouldn't even start up until I chmodded it.Chapple
mysqld_safe command worked right away... you made my day. thank youCattima
C
5

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

Caraviello answered 12/1, 2017 at 5:19 Comment(0)
W
2

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.

Weightlessness answered 31/1, 2011 at 3:37 Comment(0)
V
1

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
Vivianaviviane answered 19/9, 2013 at 19:50 Comment(0)
T
0

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.

Tannie answered 14/11, 2016 at 16:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.