8/23/2011

MySQL with ruby on rails on Mac OS X Lion

1, download a 64bit version of mysql for mac at
http://dev.mysql.com/downloads/mysql/
2, install mysql
3, add the following into your .bash_profile:
export PATH="$PATH:/usr/local/mysql/bin"
export ARCHFLAGS="-arch x86_64"
export DYLD_LIBRARY_PATH="/usr/local/mysql/lib:$DYLD_LIBRARY_PATH"
4, install mysql gem by this command:
gem install -mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

when I was doing all this, I forgot to export the DYLD_LIBRARY_PATH,
and either for the fourth step, I got the following error when running
'rake db:create':
Couldn't create database for {"reconnect"=>false, "encoding"=>"utf8",
"username"=>"root", "adapter"=>"mysql", "database"=>"xxx",
"host"=>"127.0.0.1", "pool"=>5, "password"=>"xxx",
"socket"=>"/tmp/mysql.sock"}, charset: utf8, collation:
utf8_unicode_ci (if you set the charset manually, make sure you have a
matching collation)

hope this may help you :)

8/19/2011

Way to switch your ruby gem version

Here is a common way to upgrade or downgrade your ruby gem
just two simple commands:

1, sudo gem install rubygems-update -v THE_VERSION_YOU_WANT
this will download and install a specified version of ruby gems
2, sudo update_rubygems
this will execute the ruby gems update script to actually update
your ruby-gems