Thursday, March 20, 2008

The Leopard, the Noob and MySQL

After much waiting, I go another Macbook Book Pro last week. The machine has 2.4GHz Intel core 2 Duo 2GB RAM 200GB HD and is running Max OS X v 10.5.2. Thanks to Carlos for pitching in the F&F Apple Discount (obrigado muito). After moving documents off the Vaio, next came the decision - to buy or not to buy Microsoft Office. I downloaded OpenOffice for Mac but my experience was so-so. Every time I launched OpenOffice, an X11 console window would pop-up (and an icon would appear in the Doc yuk). Moreover, OpenOffice would timeout (apparently waiting for X11 to start) and then things would work Ok. I read up on it and it turns out this is an issue with OpenOffice and Max OS X until the native version due out "later this year". My faith shaken, I went ahead and ordered MS Office online... Luckly, the following day, Suren clued me on NeoOffice and it is just perfect. So I canceled my order so I am still 100% MS free.

Next came the Rails environment. If you're into Raisl and Leopard, you know that Ruby, Rails, Mongrel, Sqlite3 and SVN come pre-installed with Leopard. Its all good and it all worked out of the box. HOWEVER, I wanted to get on MySQL since the others I am collaborating with on a project are also on it... This is where things got interesting.

First, the question was -- which version to install? Answer: Go with v 5.0.51a MySQL 5.0 Community Server - GA release. There is an alpha of version 5.2 and 6.0 but I opted for the GA (Generally Available) release.

The release comes with two packages: 1) mysql-5.0.51a-osx10.5-x86.pkg this is the server 2) MySQLStartupItem.pkg this is a bit which along with MySQL.perfPane that comes in the installation (disk image as its called) allows you to start and stop the server from a graphic interface. This is when the plot thickened.

The first package (server) installed without incidents. I was able to tickle the server using the following command line commands:

shell> cd /usr/local/mysql shell> sudo ./bin/mysqld_safe (ENTER YOUR PASSWORD, IF NECESSARY)(PRESS CONTROL-Z) shell> bg (PRESS CONTROL-D OR ENTER "EXIT" TO EXIT THE SHELL)
Meanwhile, I had been reading blogs and forum posts on the subject and it was becoming clearer that something was up with MySQL and Leopard (people talking about stuff not starting and not being installed properly) I soon found out.The time to install the second package (MySQLStartupItem) which I did and it went ahead through the usual installer wizard steps and congratulated me on a successful installation. But when I tried to use the Startup Item to start MySQL using the command below it was no dice.
shell> sudo /Library/StartupItems/MySQLCOM/MySQLCOM start
It turns out there is nothing under /StartupItems Gaah! The package installs /MySQLCOM under /usr/local/ go figure.

After much reading and pocking around, I came across bug 25008 on the MySQL site. The bug was first opened 12 Dec 2006 (title: Mac OS X's StartupItem does not work) and has been alive since. On Feb 7, 2008, 7 one Andrew Lindley reported the identical problem to mine.

After a few exchanges with one Mattias Jonsson, it turns out that a fix is to 1) move the MySQLCOM directory to the right place 2) Install and use a corrected MySQL.prefPane

However, if you are a newb like me, you may have trouble with the "mv" command. Thanks to Mattias, the correct syntax for this is
sudo mv /usr/local/MySQLCOM /Library/StartupItems/
The other newb thing I couldn't do is add usr/local/mysql/bin to my bash shell PATH so that I could start mysqladmin from the command line. Everything I read assumed that I knew where the said profile file needs to go. So the right thing to do here is create a .bash_profile file under /Users/ Many thanks to Jeff McLeman for guiding me through this.

The contents of the .bash_profile file as follows:
PATH=$PATH:/usr/local/mysql/bin
MANPATH=$MANPATH:/usr/local/mysql/man
The last newb thing I had to figure out is where/what the "Perf Panel" is that you're supposed to use to start/stop the server. Again, thanks to Mattias, it turns out that this is nothing more than good 'ol "System Preferences". If all went well, launch it and you should see a MySQL icon under "Other". See?


Picture 1
Originally uploaded by roupen


So moral of the story :) In 10+ years since I used Unix little has changed in the once analogy I read about Unix in an article title "if airlines were operating systems" . Its still a lot of hacking, haggling, heckling and friends helping friends. In the end, it all worked out and its all open source and $FREE$. Yey!.

2 comments:

Unknown said...

Fix worked perfect thank you!

PINEAPPLE 'N HAM said...

I'm glad it was helpful :)