I've spent literally a week trying to get MySQL to work with Ruby On Rails. After much hair pulling, screaming, and crying I finally figured it out. Much of this article is based on the following command:
sudo gem install mysql -- - with-mysql-config=/usr/local/mysql/bin/mysql_config
Contrary to the many articles out there, mysql doesn't necessarily install to the same path every time. The most common location for it to be installed to is
/usr/local/mysql/. Don't take this as gospel when you see it splashed around the Intarwebs. In fact, your install location could well be
/opt/local/var/db/mysql5/ depending on the version. To find out where your mysql version is simply run "location mysql_config" and it should narrow your search results. If it's the first time you've run location then the terminal will give you command required to install it. So, first of all, locate the correct mysql location.
sudo gem install mysql doesn't necessarily do what you want it to do. There's no real way of checking until you specify
--with-mysql-config as a parameter option to the gem install. This will fall over and give you some error such as "can't connect to local MySQL server through socket '/tmp/mysql.sock'". Realistically this doesn't help you. What it really means is that you're probably pointing to the wrong path, so as the previous step mentioned, make sure you find the correct path.
It's a very good idea to install the version of XCode from the Snow Leopard DVD, otherwise things won't work. Also, Snow Leopard supports 64-bit installs now which is another reason to use it.
Personally I built from source. The last link I have provided shows how to do this. There's many-a-reason to do it, most of all is the flexibility. It will take roughly half an hour to do.
Posted: 2010-02-04 20:31:13 UTCblog comments powered by Disqus