I am attempting a fresh install of mysql on a new iMac running OSX 10.11. I downloaded the latest 10.10 dmg and followed installation directions, but when I try to run mysql, I get the
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2).
I have spent several hours reading answers here and elsewhere as to how to fix it, and nothing has worked so far.
What I know:
The /tmp/mysql.sock file has been renamed /tmp/mysql.sock.lock. Apparently, if I could get mysqld to run, it would make a new socket file, but when I try to get mysqld to run (either from the Terminal or System Preferences) it just fails and produces the same error. Likewise, when I try to run mysqladmin it fails and produces the same error.
When I run mysqld_safe, it produces the following, but doesn’t clear up the socket error:
151206 16:40:20 mysqld_safe Logging to '/usr/local/mysql/data/XXXXXXs-iMac.err'.
151206 16:40:20 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
151206 16:42:01 mysqld_safe mysqld from pid file /usr/local/mysql/data/XXXXXXs-iMac.pid ended
When I ran mysql on Lion, I was always able to clear up socket errors by running mysqld_safe.
Advice?
Run the command 'sudo mysqld' from the command line to launch the server.
Related
Out of the sudden, I am getting this error:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
on mysql when I run mysql -uroot.
I haven't touched web dev for around 1 month and as soon as I wanted to return to my project, I am getting this very annoying error out of nowhere. I have trie all advice and solutions from other answers and none of them work. This includes changing permissions to 777, ownership to root, mysql etc, killing PID all of those and none of them work. I even tried re-installing mysql and still getting the same error. I even re-installed my whole macOS Mojave and still getting the same error. I mean this error doesn't even make sense...
Is mysql completely broken or I am just super dumb?
Has anyone had this issue? If so how did you solve it?
The error says, it's using the socket /tmp/mysql.sock and failed.
Try to troubleshoot with the below things.
check the process status of mysqld and confirm its running or not. If running which socket is using.
ps -ef | grep -i mysqld
Based on the socket file try login to the MySQL through command line.
mysql -uroot -p -S <<file.sock>>
Check the my.cnf to make sure which socket file its mentioned under the [client] group option.
In your case, probably the mysql instance reading the socket from my.cnf files where it placed somewhere. Check the hierarchy of the configuration file usage by mysqld which may be located in either the /etc or /etc/mysql
I tried a lot to install MySQL8 via Homebrew on Mac 10.14.5. I was running MySQL 5.7 before that and did the following: I removed MySQL completely via this tutorial: https://coderwall.com/p/os6woq/uninstall-all-those-broken-versions-of-mysql-and-re-install-it-with-brew-on-mac-mavericks
After that I run mysql and got the message that the command was not known. So I installed mysql with brew install mysql. After installation I did brew link --force mysql and got Warning: Already linked: /usr/local/Cellar/mysql/8.0.19
I edited /usr/local/etc/my.cnf and added default-authentication-plugin=mysql_native_password in the [mysqld] section. After that I restartet the service using brew services restart mysql
brew services list shows me this now:
mysql started root /Library/LaunchDaemons/homebrew.mxcl.mysql.plist
mysql#5.7 stopped
However, when I type mysql in the terminal I get this:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
The /tmp/mysql.sock does not exist.
When I change the host in the my.cnf file from localhost to 127.0.0.1 this error will change into this:
ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 54
Anyone has an idea what's going on here and how I can fix it? I also googled it and found various Threads, some are saying that the permissions must be changed to this sudo chown -R _mysql:mysql /usr/local/var/mysql but this does not change anything in my case.
I just installed mySQL and when I try to type mysql in my mac terminal I'm getting
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
I tried searching for an answer but I'm still stuck. Also, I don't know if this is relevant or connected, but when I go to my preference panel to try to start mySQL it doesn't start. On some sites such as other stackoverflow pages, it says to try running "/usr/local/mysql/bin/mysqld_safe" but for me it just permission denied..
I tried to do ps -u mysql to check if it's running and it printed out and an address: usr/local/mysql/bin/mysqld --basedir=/usr/local. So I assume it's running? Even though I can't physically press the button and enable it in the preference panel which is weird.
EDIT: I typed
$ sudo /usr/local/mysql/bin/mysqld_safe
Password:
130930 11:55:15 mysqld_safe Logging to '/usr/local/mysql/data/myname-mac.att.net.err'.
130930 11:55:15 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
130930 11:55:18 mysqld_safe mysqld from pid file /usr/local/mysql/data/myname-mac.att.net.pid ended
why did it end right there?
I had this same error message for days and finally figured it out.
I had somehow gotten a my.cnf file on my computer from AMPS or possibly another MYSQL install (that I believed I had deleted).
But it turns out it was a hidden file in /etc/ that I had to manually delete. http://ianlunn.co.uk/articles/quickly-showhide-hidden-files-mac-os-x-mavericks/
Finally, I installed MySQL with homebrew one more time –– and success! It works. Also of course this time I spot a message in the homebrew setup process that points out the problem I was having:
A "/etc/my.cnf" from another install may interfere with a
Homebrew-built server starting up correctly.
Hope this helps.
I also experienced a similar error. After trying all prescribed solutions like in this related post, noticed that it was a simple solution: first make sure the mysql daemon is running. For example, on a Homebrew installation (macOS), start mysql with: brew services start mysql
I run the mysql command at the command line but I get this error:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
I've Googled a lot but I'm unable to resolve the issue.
Please HELP!
It sounds like mysql isn't running. This will tell you if it is or not:
sudo netstat -tap | grep mysql
That's because the path you specified doesnt have the socket required to connnect to the mysql. This problem has happened with me. Either you can reinstall mysql or search for the mysqld.sock and then move it to the specified directory.
Try running this command to start the mysql server
/etc/init.d/mysql start
/etc/init.d/mysql restart
I recently upgraded to a new macbook pro and haven't been able to get mysql to install. I have been trying to install using the:
mysql-5.5.8-osx10.6-x86_64.dmg
which 'should' work for my machine, but is not. After installing the three pieces (mysql.pkg,
startup.pkg, prefpane) I get nothing. Trying to start mySQL through the prefpane freezes sysprefs. Trying to start via the terminal gets this error:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
So I deleted all of the mysql install files and reinstalled following these instructions:
https://discussions.apple.com/message/12820394
when I get to the step where I would set up the root password i get the following error:
error: 'Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/tmp/mysql.sock' exists!
This is perhaps due to the fact that there are no mysql related files in /tmp ? I can't find anything *.sock anywhere on my machine at all. I really don't know much about server admin, so I could be totally confused and off here.
It can have moved to /var/mysql/mysql.sock. I think it is the new position. You may need to point your php.ini to that or create a symbolic link to ln -s /var/mysql/mysql.sock /tmp/mysql.sock...