views:

61

answers:

2

I set up Mysql5, mysql5-server and py26-mysql using Macports. I then started the mysql server and was able to start the prompt with mysql5

In my settings.py i changed database_engine to "mysql" and put "dev.db" in database_name.

I left the username and password blank as the database doesnt exist yet.

When I ran python manage.py syncdb, django raised an error

'django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: dynamic module does not define init function (init_mysql)`

How do I fix this? Do I have to create the database first? is it something else?

+1  A: 

syncdb will not create a database for you -- it only creates tables that don't already exist in your schema. You need to:

  • Create a user to 'own' the database (root is a bad choice).
  • Create the database with that user.
  • Update the Django database settings with the correct database name, user, and password.
Craig Trader
when I create the database from the mysql prompt, where does it store the database? how do I find the path for it?
Ali
@Ali, that depends upon your OS and your configuration files. On most Unixes, you'd find the database files under /var/lib/mysql. For more details, see: http://dev.mysql.com/doc/refman/5.5/en/installation-layouts.html
Craig Trader
+1  A: 

You need to install MySQLdb: http://sourceforge.net/projects/mysql-python/

This can be a painful process depending on your setup. See other discussions on SO regarding MySQLdb install on mac os x:

http://stackoverflow.com/questions/1448429/how-to-install-mysqldb-python-data-access-library-to-mysql-on-mac-os-x

EDIT: Sorry, skimmed past the fact that you already installed MySQLdb via py26-mysql, but this error seems to point to something that went wrong with that install. I've had lots of problems with MySQLdb on Mac OS X, always something different I have to do to make it work.

Brian Stoner