Ruby on Rails 3 Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ on OSX

First, to find your socket file:

mysqladmin variables | grep socket

For me, this gives:

| socket                                            | /tmp/mysql.sock                                                                                                        |

Then, add a line to your config/database.yml:

development:
  adapter: mysql2
  host: localhost
  username: root
  password: xxxx
  database: xxxx
  socket: /tmp/mysql.sock

Leave a Comment