I recently tried installing MySQL with homebrew (brew install mysql
) and when I try to run it I get the following error:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
There is no /tmp/mysql.sock
nor a /var/lib/mysql.sock
.
I've searched and haven't found any mysql.sock
file.
How can I fix this?
The file
/tmp/mysql.sock
is probably a Named-Pipe, since it's in a temporary folder. A named pipe is a Special-File that never gets permanently stored.If we make two programs, and we want one program to send a message to another program, we could create a text file. We have one program write something in the text file and the other program read what our other program wrote. That's what a pipe is, except it doesn't write the file to our computer hard disk, IE doesn't permanently store the file (like we do when we create a file and save it.)
A Socket is the exact same as a Pipe. The difference is that Sockets are usually used over a network -- between computers. A Socket sends information to another computer, or receives information from another computer. Both Pipes and Sockets use a temporary file to share so that they can 'communicate'.
It's difficult to discern which one MySql is using in this case. Doesn't matter though.
The command
mysql.server start
should get the 'server' (program) running its infinite loop that will create that special-file and wait for changes (listen
for writes).After that, a common issue might be that the MySql program doesn't have permission to create a file on your machine, so you might have to give it root privileges
Looks like your mysql server is not started. I usually run the stop command and then start it again:
Same error, and this works for me.
I faced the same problem on my mac and solved it, by following the following tutorials
https://mariadb.com/resources/blog/installing-mariadb-10116-mac-os-x-homebrew
But don't forget to kill or uninstall the old version before continuing.
Commands:
When you got the server running via
you should see the socket in /tmp/mysql.sock. However, the system seems to expect it in /var/mysql/mysql.sock. To fix this, you have to create a symlink in /var/mysql:
This solved it for me. Now my phpMyAdmin works happily with localhost and 127.0.0.1.
Credit goes to Henry
Try to connect using "127.0.0.1" instead "localhost".
just to complete this thread. therefore MAMP (PRO) is used pretty often
the path here is