python

学习过程中总结的经验

博客园 首页 新随笔 联系 订阅 管理

由于外键只支持innodb,故必须让默认的表引擎为innodb

 

1.可通过修改mysql的设置,在my.cnf 添加一行 default-storage-engine=INNODB,重启引擎,这样mysql <<show engines

就可以看到默认引擎为INNODE了。

2.设置django的project的setting.py里面的database相关的设置,如下:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', '
sqlite3' or 'oracle'.
        'OPTIONS':{
            'init_command':'SET storage_engine=INNODB',
        },
        'NAME': 'mydb',                      # Or path to database file if using sqlite3.
        'USER': 'mmog',                      # Not used with sqlite3.
        'PASSWORD': 'mmog',                  # Not used with sqlite3.
        'HOST': '/data/mysqldata/mysql.sock',                      # Set to empty string for localh
ost. Not used with sqlite3.
        'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
    }
}

posted on 2011-12-07 17:52  や尐莊徍左赱  阅读(1218)  评论(0编辑  收藏  举报