Articles clasified as "Rails & Ruby"
Go back to the homepage

Installing MySQL and mysql gem on Snow Leopard

12/17/2009

It´s really a hard job figuring out how to get MySQL and mysql gem up and running on Snow Leopard 10.6.2. I followed the instructions of various posts but was not successful yet:

First I followed this instruction http://hivelogic.com/articles/compiling-mysql-on-snow-leopard/" and build MySQL Version 5.1.39 from source. It installed successfully. When trying to login using (mysql -u root -p) mysql returned the following error: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2), that obviously meant that the MySQL Server (mysqld) was not running (ps -axf | grep mysqld).

which mysql: /usr/local/mysql/bin/mysql
which ruby: ruby 1.8.7 (2009-04-08 patchlevel 160) [i686-darwin9])
gem -v: 1.3.5
mysql: Server version: 5.1.39 MySQL Community Server (GPL)

After a lot of googling around, I found out that

1. this command can start mysqld:
sudo /usr/local/mysql/bin/mysqld_safe --user=mysql &

2. The Preference Pane MySQL Tool is probably broken in Mac OS X 10.5 and higher

3. This command should install the mysql gem correctly on Snow Leopard:
sudo gem uninstall mysql
sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
(See this post: http://stackoverflow.com/questions/1366746/gem-install-mysql-failure-in-snow-leopard

It ended up that I got the following error using something like rake db:create:
dyld: lazy symbol binding failed: Symbol not found: _mysql_init Referenced from: /opt/local/lib/ruby/gems/1.8/gems/mysql-2.8.1/lib/mysql_api.bundle Expected in: flat namespace dyld: Symbol not found: _mysql_init Referenced from: /opt/local/lib/ruby/gems/1.8/gems/mysql-2.8.1/lib/mysql_api.bundle Expected in: flat namespace

This error led me to the following post: http://cho.hapgoods.com/wordpress/?p=158, that basically tells me that the Ruby Version that came together with XCode 3.0 does not work in 64bit environments and a solution could be to install the 32bit version. Arrrgghh!

The first answer to my post @ stackoverflowled me to the right track, doing the stuff with macports.

The way I finally solved this issue was uninstalling / reinstalling XCode and all my ports as described here:
http://trac.macports.org/wiki/Migration

Ruby, Rails & CMS

12/15/2009

Excellent article from Aaron Longwell about the Ruby on Rails CMS dilemma: http://aaronlongwell.com/2009/06/the-ruby-on-rails-cms-dilemma.html

Rails-Konferenz 2009

09/02/2009

Am 01./02.September findet in Offenbach/Main die diesjährige Rails-Konferenz statt. Der Refactoring-Workshop von Mathias Meyer und Jonathan Weiss bringt neue Erkenntnisse zur besseren Code-Strukturierung, obwohl die Einleitung zum MVC-Pattern etwas kürzer hätte ausfallen können. Interessante Einblicke in die Metaprogrammierung mit Ruby gabs von Vladimir Dobriakov, obwohl mir bisher noch kein konkreter Einsatzzweck einfällt. Scaling von Rails App ist ein Thema (Jonathan Weiss, Julian Fischer) sowie die Arbeit mit OAuth, einem Protokoll für die Authorisierung einer Anwendung gegenüber einer anderen (z.B. API) mit Hilfe von Token. DataMapper als Alternative zu ActiveRecord bietet eine Menge interessanter Features und soll wohl in Rails 3 (Release Ende 2009) integriert sein.