Rails on Snow Leopard

In particular, if you’re putting Rails on Snow Leopard to work on a
project that you started on Linux.

If you run rake db:create and see an error like this:

Couldn’t create database for {“reconnect”=>false, “encoding”=>“utf8”,
“username”=>“root”, “adapter”=>“mysql”, “database”=>“app_development”,
“pool”=>5, “password”=>nil, “socket”=>"/var/run/mysqld/mysqld.sock"},
charset: utf8, collation: utf8_unicode_ci (if you set the charset
manually, make sure you have a matching collation)

or if you run rake db:migrate and see an error like this:

rake aborted!
Can’t connect to local MySQL server through socket ‘/var/run/mysqld/
mysqld.sock’ (38)

The problem is that the mysqld.sock file is stored in a different
location in Snow Leopard than it is in Linux.

I found the solution here:

In short, change the socket: line in your database.yml to point to /

Having lost a day getting this stuff working, I’m posting it here to
be crawled and made public, for the sake of posterity.

Other useful directions are here:
and here:

It’s likely that the mysql gem as specified in those links won’t work
for you. Try using:

sudo env ARCHFLAGS="-arch x86_64" gem install mysql – --with-mysql-

Thanks acreadinglist!

Yeah it is a good idea to have that one here. I’ve seen it many times
when moving from OSX to Ubuntu systems. And I always scratch my head
thinking how I fixed it last time :slight_smile:

I think I’ve seen it also when the mySql passwords differ between
systems + the socket of course.


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs