整合了两个URL而来。。
1,http://www.phodal.com/blog/django-mezzanine-sqlite3-migrate-mysql/
2,http://www.ziqiangxuetang.com/django/django-data-migration.html
A.先建立一个SLAVE数据库
DATABASES = { "default": { "ENGINE": "django.db.backends.sqlite3", "NAME": "dev.db", "USER": "", "PASSWORD": "", "HOST": "", "PORT": "", }, "slave": { "ENGINE": "django.db.backends.mysql", "NAME": "phodal", "USER": "root", "PASSWORD": "", "HOST": "", "PORT": "", }, }
B.然后,在MYSQL建立空的数据库,将表结果从主库弄到从库:
CREATE DATABASE phodal CHARACTER SET utf8 COLLATE utf8_general_ci;
python ./manage.py syncdb --database slave
C.确保每个APP的SQL过程语句生成,没有的话,运行以下语句:
python manage.py makemigrations FAT
D.将SQLITE主库的数据导出:
python manage.py dumpdata > mysite_all_data.json
E.切换主库和从库的setting.py设置,将MYSQL设置为主库,导入数据。
python manage.py loaddata mysite_all_data.json
如果静态文件CSS.JS指向错误,则运行:
python manage.py collectstatic
然后将静态文修的放到合适的位置。
时间: 2024-10-02 06:28:53