views:

160

answers:

4

I've had Django running with Sqlite for a while. I then installed WAMP, and I now want to get ready for a production run, and would like to switch to MySql. Is there a straightforward way of telling it about the MySql instance that is running with WAMP?

+1  A: 

Modify the database options in settings.py.

Ignacio Vazquez-Abrams
Yes, but how do I tell it which MySql to use, for instance to use the one that comes with WAMP?
Rhubarb
You point it to an IP address that the MySQL server has bound to.
Ignacio Vazquez-Abrams
+1  A: 

Hi Rhubarb,

as Ignacio already has pointed out you have to modify your settings.py. If you are using the latest version of Django (that would be 1.2.x) youe settings.py will contain this section:

DATABASES = {
    'default': {
        'ENGINE': '',
        'NAME': '',
        'USER': '',
        'PASSWORD': '',
        'HOST': '',
        'PORT': '',
    }
}

Here you can define which database you are using.

In your case this section should look like this:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': '',
        'USER': 'your-mysql-username',
        'PASSWORD': 'your-mysql-users-password',
        'HOST': 'localhost',
        'PORT': '3306',
    }
}

If your are running a MySQL server it is identified by its IP address (localhost = 127.0.0.1) and its port (3306). You could run several MySQL server instances on the same computer. Each of this instances could be identified by the combination of its IP and port.

Hope that helps you.

Jens
A: 

By default, these are the settings you should use with WAMP/MySQL I believe...

DATABASE_ENGINE = 'django.db.backends.mysql'
DATABASE_NAME = ''
DATABASE_USER = 'root'
DATABASE_PASSWORD = ''
DATABASE_HOST = ''
DATABASE_PORT = ''
Mark