Showing posts with label mysql. Show all posts
Showing posts with label mysql. Show all posts

Thursday, November 29, 2007

Python 25 & MySQL on Leopard

There was a bit of trouble when I tried to use macports to install the excellent Trac project management and issue tracking application. Specifically, the py25-mysql port did not compile correctly.

Trolling through the InterWeb, I found this post about a fix to compile the python module from scratch. The post, however, has more instructions than are necessary, so here is my revised procedure:

  1. Download the source from here.
  2. Unpack the archive and edit the _mysql.c file to comment out lines 37-39:

    // #ifndef uint
    // #define uint unsigned int
    // #endif

  3. Edit the site.cfg file to set the mysql_config path. For me this was:

    mysql_config = /usr/local/mysql/bin/mysql_config

  4. Compile as normal

    python setup.cfg config
    python setup.cfg build
    sudo python setup.cfg install


Now if only someone would make these changes in the port file, then trac installs would be super easy, instead of just easy-ish.

Wednesday, November 14, 2007

OS X 10.5 Leopard and MySQL

UPDATE: The Mysql.com supplied preferences pane now works. Just use that.

It seems that the once super-simple MySQL on OS X install is no more in Leopard, that is until the MySQL developer community catches up. Now there is a small amount of terminal-fu that must be done to enable a mysql server on OS X, which has been covered in some other blog posts. But I will repeat the procedure here, since I added a script or two to make things a tiny bit simpler for me.
First, if you did a clean install of Leopard, then you need to download and install the MySQL server for OS X from the mysql.com. Just install the main server, not the preferences pane or the start up item.
Next download this launchd file and copy it to "/Library/LaunchDaemons/com.mysql.mysqld.plist"
Next change the ownership to root. Might as well set proper permissions while you are at it:

sudo chown root:wheel /Library/LaunchDaemons/com.mysql.mysqld.plist
sudo chmod 644 /Library/LaunchDaemons/com.mysql.mysqld.plist


Next load the file into launchd using launchctl

sudo launchctl load /Library/LaunchDaemons/com.mysql.mysqld.plist

Finally, you can create some shell script to load and unload the server at will and place it where you normally place your binaries (mine is ~/bin/sqlserverctl ):
#!/bin/sh
case "$1" in
start)
sudo launchctl load -w /Library/LaunchDaemons/com.mysql.mysqld.plist
;;
stop)
sudo launchctl unload -w /Library/LaunchDaemons/com.mysql.mysqld.plist
;;
*)
echo "USAGE: $0 {start|stop}"
;;
esac

UPDATE: There was a small error in my start script, namely and extra space in the case statement, it has been modified and fixed above.

UPDATE: If you install MySQL via MacPorts, then use the "+server" varient and use this launchd file instead
/Library/LaunchDaemons/org.macports.mysql5.plist