I have already install mysql 5.1 on my windows 10 machine , and I can connect mysql from python by :
import pymysql
conn=pymysql.connect(host='localhost',user='root',password='MYSQLTB',db='shfuture')
then I download django frame and try to use it to connect mysql , what I do is :
create a my.cnf file content is :
[client]
database = shfuture
host = localhost
user = root
password = MYSQLTB
default-character-set = utf8
change settings.py to :
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'OPTIONS': {
'read_default_file': os.path.join(BASE_DIR, 'my.cnf'),
},
}
}
then run :
python manage.py runserver
but got a error :
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module.
Did you install the MySQL client?
Do I still need to install an addition MySQL in Django virtual env? if I can use the existing MySQL instead