# Rails on Snow Leopard

**URL:** <https://www.ruby-forum.com/t/rails-on-snow-leopard/183968>\
**Category:** Rails\
**Created:** [February 23, 2010, 8:28am UTC](https://www.ruby-forum.com/t/rails-on-snow-leopard/183968 "2010-02-23T08:28:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![acreadinglist](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ccd318/32.png) [@acreadinglist](https://www.ruby-forum.com/u/acreadinglist)\
**Post date:** [February 23, 2010, 8:28am UTC](https://www.ruby-forum.com/t/rails-on-snow-leopard/183968/1 "2010-02-23T08:28:35Z")

</div>

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:

> <https://superuser.com/questions/102664/rails-cant-connect-to-local-mysql-server-through-socket-var-run-mysqld-mysql/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:

> **[Dan Benjamin](https://danbenjamin.com)**
>
> Dan Benjamin's personal website.

and here:

> **[Dan Benjamin](https://danbenjamin.com)**
>
> Dan Benjamin's personal website.

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

---

<div class="post-metadata">

**Author:** ![acreadinglist](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ccd318/32.png) [@acreadinglist](https://www.ruby-forum.com/u/acreadinglist)\
**Post date:** [February 23, 2010, 9:04am UTC](https://www.ruby-forum.com/t/rails-on-snow-leopard/183968/2 "2010-02-23T09:04:13Z")

</div>

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.
