views:

636

answers:

2

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:

I build MySQL Version 5.1.39 from source and 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.

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

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 versionof MySQL.

Any suggestions, how to proceed?

+2  A: 

While building from source is not necessarily a bad idea, even if the official distribution is built using a better compiler, using MacPorts (http://www.macports.org/install.php) to do it is probably a better idea than a self-built installation.

Although you can wrangle the OS X supplied Ruby and MySQL into shape, in my experience it's easier to work entirely within the MacPorts realm (/opt) and leave your original distribution unmolested.

A further advantage is you get a more up-to-date Ruby executable. 10.6 ships with 1.8.7p72 where MacPorts provides 1.8.7p174, for instance.

Example:

sudo port install mysql5
sudo port install mysql5-server
sudo port install rb-mysql
tadman
Thanks a lot for your help. You really led my to the right track. Unfortunately MacPorts had also some problems with installing mysql, so at the end I ended up following the steps suggested here: http://trac.macports.org/wiki/Migration. After uninstalling and reinstalling all my ports, everything seems to work fine now.
auralbee
A: 

Follow this link please, http://hivelogic.com/articles/compiling-mysql-on-snow-leopard/

leomayleomay
That were exactly the instruction I followed first, unfortunately without success. My issue was obviously caused by some broken ports after I updated MacOSX from Leopard to Snow Leopard.
auralbee