2013-01-04 42 views
0
DATABASES = { 
'default': { 
    'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'. 
    'NAME': 'djangodb',    
    'USER': 'root',     
    'PASSWORD': '',     
    'HOST': '',      
    'PORT': '',      
} 
    } 

我创建了一个数据库djangodb现在我 尝试创建表 使用此命令mysql数据库不工作的Django

./manage.py syncdb 

我有望获得

Creating table auth_message 
Creating table auth_group 
Creating table auth_user 
Creating table auth_permission 
Creating table django_content_type 
Creating table django_session 
Creating table django_site 
Creating table blog_blogpost 

但我得到这个错误:

django.core.exceptions.ImproperlyConfigured: Error loading MySqldb module: no module named MySqldb 

我甚至试着搭起一个主机127.0.0.1。任何人都可以弄清楚发生了什么。

回答

4

你安装了MySQL-python吗?

pip install mysql-python 
1

the docs

If you're using MySQL, you'll need the MySQL-python package, version 1.2.1p2 or higher. You will also want to read the database-specific notes for the MySQL backend.