Can’t connect to local MySQL server through socket

by Damien on November 29, 2007

After recently reinstalling MySQL 5 on my OSX Leopard machine Rails stopped being able to connect to it – every time I’d start script/server it would say:

Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’

After spending some time looking to see if maybe the socket file had been put in a different location I finally found the issue: MySQL wasn’t creating a socket file at all and needed to be told to do so. So, if you start receiving the above error, just make sure that the file /etc/my.cnf has the two socket lines as mentioned below, one in the [mysqld] section, the other in the [client] section:

[mysqld]
bind-address = 127.0.0.1
socket=/tmp/mysql.sock

[client]
socket=/tmp/mysql.sock
Bookmark and Share

Other Posts That Might Interest You

  1. Ruby on Rails connection to SQL Server
  2. Installing Ruby, Rails, and MySQL on Mac OS X with Macports
  3. Install Ruby, Rails, and MySQL on Mac and Windows
  • Juan
    In my Leopard there's no such my.cnf file at all (I've looked for it with Textwrangler)
blog comments powered by Disqus

Previous post:

Next post: