Installing MacPorts and MySQL on Leopard
Jan 15th, 2008 by denis
I recently had to re-install a development environment on a Mac Pro so I kept track of the steps as I went. Here’s the simplest way to get MacPorts and MySQL installed on Leopard.
- Install XCode 3.0 from Leopard Install Disk 2
- Download MacPorts installer from http://www.macports.org/install.php and run.
Then, add the following to ~/.bash_profile (and then restart your Terminal):
export PATH=/opt/local/bin:/opt/local/sbin:$PATH export MANPATH=/opt/local/share/man:$MANPATH export ARCHFLAGS="-arch i386" bind 'set completion-ignore-case on'
That last line is not strictly needed but I like to be able to tab through directory names without caring about the capitalisation. Finally run:
$ sudo port -v selfupdate
OK, that’s MacPorts out of the way, on to MySQL:
$ sudo port install mysql5 +server $ sudo -u mysql mysql_install_db5 $ cd /opt/local $ sudo /opt/local/lib/mysql5/bin/mysqld_safe
Add the following as /opt/local/etc/mysql5/my.cnf:
[mysqld_safe] socket=/tmp/mysql.sock
Lastly, try it out (and set it to start on reboot) with:
$ sudo /opt/local/lib/mysql5/bin/mysqld_safe $ sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist $ sudo ln -s /tmp/mysql.sock /opt/local/var/run/mysql5/mysqld.sock
If I’ve missed anything, let me know.
Very good instruction.
One suggestion here for mysql: by default the mysql database is not transactional. To make the tables be able to support ACID transactional feature, you need to configure the default_storage_engine, otherwise, you have to explicitly specify the engine for each table.
Making Mysql use InnoDB by default, you need to add the following to /etc/my.cnf (In this case, I think it will be /opt/local/etc/mysql5/my.cnf)
# mysqld configuration file for InnoDB tables
#
[mysqld]
default-table-type=InnoDB
default-storage-engine=InnoDB
innodb_data_file_path = ibdata1:10M:autoextend
innodb_lock_wait_timeout=0
innodb_data_home_dir = /usr/local/mysql/data
Restart the Mysql and login, run “show engines” you should see the InnoDB is marked as default (Before it would be MYISAM which is not transactional)
Cheers,
Miao