I recently got a new MacBook Pro and had problems creating a new database for my Rails app on Snow Leopard. Running rake db:create left me with the following useless error:
Couldn’t create database for {”username”=>”root”, “adapter”=>”mysql”, “database”=>”delete_me”, “password”=>nil, “socket”=>”/tmp/mysql.sock”}, charset: utf8, collation: utf8_unicode_ci (if you set the charset manually, make sure you have a matching collation)
Although I could manually access MySQL via command line and create the necessary databases, rake continually failed. It turns out that the MySQL gem needed to be compiled for a 64-bit OS as mentioned in this post:
http://weblog.rubyonrails.org/2009/8/30/upgrading-to-snow-leopard
The key command to run is:
sudo env ARCHFLAGS=”-arch x86_64″ gem install mysql — –with-mysql-config=/usr/local/mysql/bin/mysql_config
Then you should be able to run your rake tasks and ultimately get Rails talking to your MySQL database.
[...] to http://www.techskater.com/ruby-on-rails/problems-with-mysql-gem-and-rake-on-snow-leopard/ this seems to be related to Snow Leopard and MySql 32bit vs. 64bit. On Snow Leopard the Gem Mysql [...]
Thank you! this was driving me nuts