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: Dan Benjamin and here: Dan Benjamin
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