Django数据库迁移 [英] Django Database Migration
问题描述
我有一个django项目,一个完整的项目,现在我想从默认的Sqlite3(默认数据库)迁移到mysql.我使用的是Mac OS,我不知道如何实现此过程.任何对如何进行切换都有完整指南的人都将不胜感激.
Hi have a django project a full project now I want to migrate to mysql from the default Sqlite3 which is the default database. I am on a Mac OS and I don't know how to achieve this process. Any one with a complete guide on how to make the switch would be appreciated.
推荐答案
转到项目的设置文件并使用正确的数据库连接来编辑数据库
Go to your project's settings file and edit DATABASES with proper database connection
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'DB_NAME',
'USER': 'DB_USER',
'PASSWORD': 'DB_PASSWORD',
'HOST': 'localhost',
'PORT': '3306',
}
}
现在打开mysql并按照数据库设置中的说明创建数据库.
Now open mysql and create database as you give in DATABASE settings.
转到您的项目-
./manage makemigrations
./manage makemigrations
./管理迁移
这将在指定的数据库名称中创建所有表.
This will create all the tables in the specified database name.
这篇关于Django数据库迁移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!