简体   繁体   中英

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

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!

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

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

Try running

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM