Rails on Snow Leopard

30 views
Skip to first unread message

acreadinglist

unread,
Feb 23, 2010, 2:27:01 AM2/23/10
to Ruby on Rails: Talk
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:
http://superuser.com/questions/102664/rails-cant-connect-to-local-mysql-server-through-socket-var-run-mysqld-mysqld/102677#102677

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

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: http://hivelogic.com/articles/compiling-mysql-on-snow-leopard
and here: http://hivelogic.com/articles/compiling-ruby-rubygems-and-rails-on-snow-leopard

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-
config=/usr/local/mysql/bin/mysql_config

comopasta Gr

unread,
Feb 23, 2010, 3:04:13 AM2/23/10
to rubyonra...@googlegroups.com
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 :-)

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

Cheers.
--
Posted via http://www.ruby-forum.com/.

Reply all
Reply to author
Forward
0 new messages