Setting up Django with MySQL on Mac OS X Lion
January 16, 2012
Software
Surprisingly, this is a lot more annoying that I thought it would be. Some notes to the forgetful future me:
- Download the MySQL .dmg installer (64-bit). The registration form can be skipped.
- Install MySQL, the MySQLStartupItem, and the MySQL.prefPane in that order (See http://stackoverflow.com/questions/6317614/getting-mysql-work-on-osx-10-7-lion)
- Open up the MySQL preference pane and make sure the server is started.
- Edit
~/.bash_profile
and make sure that the mysql bin directory is in the path (/usr/local/mysql/bin
). (The MySQL-python package needs to callmysql_config
) - Add a libmysqlclient symlink:
sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
pip install MySQL-python
Phew. Don’t forget to update your django SETTINGS file for running locally:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': DATABASE_NAME,
'USER': USER,
'PASSWORD': PASSWORD,
'HOST': 'localhost'
}
}