Ovid
Ovid

Reputation: 11677

OS X Mavericks: mysql socket defined in my.cnf, but not getting created

I'm trying to install mysql5 (the latest from Oracle, via .dmg) on OS X Mavericks. My /opt/local/my.cnf looks like this:

[client]
socket=/tmp/mysql.sock

[mysqld]
socket=/tmp/mysql.sock

[safe_mysqld] 
err-log=/var/log/mysqld.log 
pid-file=/var/run/mysqld/mysqld.pid

When I try to connect, I get the following:

$ mysql5 -u root -p
Enter password: 
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

And there is no /tmp/mysql.sock file created.

Here's my /tmp dir:

$ ls -l /tmp
lrwxr-xr-x@ 1 root  wheel  11 Oct 24 08:31 /tmp -> private/tmp

I've also tried forcing the socket from the command line:

$ time sudo mysqld_safe5 --socket=/tmp/mysql.sock
Password:
131221 07:26:02 mysqld_safe Logging to '/opt/local/var/db/mysql5/Macintosh.local.err'.
131221 07:26:02 mysqld_safe Starting mysqld daemon with databases from /opt/local/var/db/mysql5
131221 07:17:26 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended

I know it's reading the conf file because if I remove it, I get a different socket location when I attempt to connect:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/opt/local/var/run/mysql5/mysqld.sock' (2)

But again, no luck. What do I need to do to get that socket created?

Upvotes: 3

Views: 2656

Answers (2)

Ashay
Ashay

Reputation: 11

Change your /tmp folder to have permission for MySQL user. (chown mysql:mysql /tmp or chmod 777 /tmp would resolve your issue.)

Upvotes: 1

Thomas Sibley
Thomas Sibley

Reputation: 1

Try using dtrace to see if mysqld is actually opening a socket, and if so, where. You'll also be able to tell what config files are being read by the server, although that doesn't seem to be the issue since passing --socket=... doesn't work.

I'm used to strace on Linux but recently started using dtrace at work. Here's a pretty simple example of how to trace open(2) calls, which you could modify to trace socket creation, or just all syscalls: https://github.com/tsibley/dtrace-scripts/blob/master/trace-open.d

Upvotes: 0

Related Questions