CurveGamma
CurveGamma

Reputation: 4559

Django MySql setup

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?

Upvotes: 0

Views: 5065

Answers (2)

Brian Stoner
Brian Stoner

Reputation: 158

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.

Upvotes: 1

Craig Trader
Craig Trader

Reputation: 15669

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.

Upvotes: 1

Related Questions