ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock'

前端 未结 30 1355
南旧
南旧 2020-12-04 05:14

I installed MySQL on Mac OS X Mountain Lion with homebrew install mysql, but when I tried mysql -u root I got the following error:

30条回答
  •  被撕碎了的回忆
    2020-12-04 05:47

    I have tried every possible way to solve this issue, like ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock, uninstall and reinstall mysql, make sure mysql is running on xampp but none of it still worked.

    Finally, I open up my.cnf (config file) and copy the socket path (make sure to copy the full path else it won't work). Then I perform this command in my terminal

    mysql --socket=/Applications/XAMPP/xamppfiles/var/mysql/mysql.sock
    

    Lo, and behold, mysql launchs.

    This solution will only work if your MySQL is shown running on Xampp/Ampps, but in terminal it is still not connecting to the right socket when you have already attempted something like:

    ./mysql -u root
    

    or

    brew services start mysql
    

    I hope this helps!

提交回复
热议问题