[Django]-How do I tell Django to use MySql from a WAMP install?

3πŸ‘

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

1πŸ‘

Modify the database options in settings.py.

0πŸ‘

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 = ''
πŸ‘€mpen

0πŸ‘

first install mysqldb module for python by typing following command:

easy_install mysql-python

on command prompt/python client and then modify your settings.py:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'Database Name',
        'USER': 'Database Username',
        'PASSWORD': 'Database Password',
        'HOST': 'localhost',
        'PORT': '3306',
    }
}

Leave a comment