0

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?

Ali
  • 4,311
  • 11
  • 44
  • 49
  • 2
    Are you using the Python version that's also from MacPorts? Typically you can't use the system version of Python with MacPorts-obtained extension modules. – Alex Martelli Jul 31 '10 at 03:41
  • No I was using python 2.6 that I installed myself. I also have virtual enviroments working as I am using Pinax. Shall I install python 2.6 from macports? anything else? – Ali Jul 31 '10 at 03:51

2 Answers2

1

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
  • 15,507
  • 6
  • 37
  • 55
  • when I create the database from the mysql prompt, where does it store the database? how do I find the path for it? – Ali Jul 31 '10 at 16:34
  • 1
    @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 Jul 31 '10 at 18:37
1

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:

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.

Community
  • 1
  • 1
Brian Stoner
  • 158
  • 1
  • 7