Mountain Lion: Can't connect to local MySQL server through socket '/tmp/mysql.sock'

随声附和 提交于 2019-12-11 05:53:14

问题


I installed mysql via homebrew. I ran the two commands brew suggests:

unset TMPDIR

mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp

When I tried to run the mysql_secure_installation script, I receive this error:

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

A separate thread led me to believe it had to do with permissions: connect to local MySQL server through socket

I ran the suggested commands substituting their mysql directory with

/usr/local/var/mysql

Yet, the problem persists. Help!


回答1:


Your socket is probably being created in a non-standard location. My Homebrew installation creates it in /tmp/mysql.sock for instance.

If you can connect to the server over the TCP/IP socket, run this:

SHOW VARIABLES LIKE '%sock%';

Otherwise, try to look for it somewhere on your system:

find / -name mysql.sock



回答2:


What is the default socket defined in /etc/php.ini?

Try running

cat /etc/php.ini | grep "mysql.default_socket"


来源:https://stackoverflow.com/questions/14821982/mountain-lion-cant-connect-to-local-mysql-server-through-socket-tmp-mysql-so

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!