天天看點

django 更改預設資料庫為MySQL

1、安裝mysql-python

pip install mysql-python

ln -s /usr/local/mysql/lib/libmysqlclient.so.20 /usr/lib64/libmysqlclient.so.20

2、修改配置檔案settings.py

DATABASES = {

    'default': {

        'ENGINE': 'django.db.backends.mysql',

        'HOST': 'localhost',

        'PORT': 3306,

        'NAME': 'osdb',

        'USERNAME': 'root',

        'PASSWORD': 'root',

    }

}

參考博文:

<a href="http://www.cnblogs.com/havenshen/p/3531489.html" target="_blank">http://www.cnblogs.com/havenshen/p/3531489.html</a>

<a href="https://shenxgan.gitbooks.io/django/content/publish/2015-07-13-django-mysql.html" target="_blank">https://shenxgan.gitbooks.io/django/content/publish/2015-07-13-django-mysql.html</a>

     本文轉自1321385590 51CTO部落格,原文連結:http://blog.51cto.com/linux10000/1961424,如需轉載請自行聯系原作者