2013-01-04 43 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.