Friday, December 12, 2008

Installing MySQL on OS X

It's actually not required to get started on Django, but I thought it would be a good idea to jump through the MySQL hoops early.

It was a bit of an adventure:

The MySql install instructions are broken for OS X. After you have
downloaded the MySql package and installed it with the usual dance,
you will probably encounter some instructions involving
"groupadd".

Various mortals seem to have gotten confused by this and
run into various smug bastards being unhelpful. Ignore the smug bastards.

===

Instead, follow the instructions at
http://www.macosxhints.com/article.php?story=20080128103022907

However, the lines

===

$ cd /Library/LaunchDaemons
$ sudo chown root com.mysql.mysqld
$ sudo chgrp wheel com.mysql.mysqld
$ sudo chmod 644 com.mysql.mysqld

===

should read:

===

$ cd /Library/LaunchDaemons
$ sudo chown root com.mysql.mysqld.plist
$ sudo chgrp wheel com.mysql.mysqld.plist
$ sudo chmod 644 com.mysql.mysqld.plist

===

Otherwise the instructions are OK.

Now it tells me to check with Console.app ... What is that?

Wahoo! There it is in Utilities. I run it and it claims mysqld is running and
ready for connections.

===

So now to find mysql; open a Terminal window.

OK, now mysql isn't in my path yet, but I can invoke a mysql session
with

/usr/local/mysql/bin/mysql

thus:

/Guido:~ tobis$ /usr/local/mysql/bin/mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.30 MySQL Community Server (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

MySql is running! Type quit . This is enough of a victory for one day.

===

In future if you want to just type mysql instead of
/usr/local/mysql/bin/mysql, you need to update your path.

Change to your home directory. Issue

touch .profile

Then edit .profile, appending the line

export PATH="$PATH:/usr/local/mysql/bin"

Note this is a hidden file. See

http://www.peachpit.com/articles/article.aspx?p=31442&seqNum=4

http://www.macworld.com/article/51830/2006/07/showallfinder.html

===

In future if you don't want to burden your machine with mysql anymore,
issue

launchctl unload com.mysql.mysqld.plist

Next step Django itself. I am expecting it to be a bit easier.

No comments: