Connect Django to your Mysql Database

Assuming you’re on a *nux system, update your site’s settings.py file with the following:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'OPTIONS' : {
            'read_default_file': '/etc/mysql/my.cnf',
        }
    }
 }

Naturally, you’ll need to create or update your my.cnf file in the /etc/mysql directory.  For my needs, I had to add the following to my.cnf:

[client]
database = put your database name here
user = put your database user name here
password = put this database user's password here
default-character-set = utf8

Leave a Reply

Your email address will not be published. Required fields are marked *