1

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!

Community
  • 1
  • 1
reneruiz
  • 2,286
  • 2
  • 19
  • 16

2 Answers2

2

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
tadman
  • 194,930
  • 21
  • 217
  • 240
  • I'm getting a lot of Permission Denied messages: find: /private/var/spool/postfix/saved: Permission denied find: /private/var/spool/postfix/trace: Permission denied find: /private/var/tmp/launchd: Permission denied find: /System/Library/DirectoryServices/DefaultLocalDB/Default: Permission denied find: /System/Library/User Template: Permission denied – reneruiz Feb 12 '13 at 14:18
  • That's normal if you're not using `find` as `root`. If this is a problem, try `sudo find / -name mysql.sock` instead. – tadman Feb 12 '13 at 17:42
  • 1
    Just adding on to the find command...putting 2> /dev/null will make the output more pretty by not displaying error messages. Full command would then be: find / -name mysql.sock 2> /dev/null – Clayton Selby Nov 12 '13 at 17:56
-2

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

Try running

cat /etc/php.ini | grep "mysql.default_socket"
Evan Lucas
  • 564
  • 2
  • 6