Migrating Database From SQLite to MySQL - koglak/SWE573 GitHub Wiki
Django has default database as SQLite. However, we will migrate database to MySQL.
1) Go to cmd and migrate your database.**
python manage.py dumpdata > db.json
2) Go to setting.py and edit code.
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'djangodatabase',
'USER': 'root',
'PASSWORD': 'Nilufer12*',
'HOST': 'localhost',
'PORT': '3306',
}
}
3) Migrate your database
python manage.py migrate
Note if you receive error: No module named 'pymysql' then try below code.
python -m pip install PyMySQL
pip install mysqlclient
4) Open your shell
python manage.py shell
5) Type below codes in same order.
from django.contrib.contenttypes.models import ContentType
ContentType.objects.all().delete()
exit()
6) Load Data
python manage.py loaddata db.json
7) Run web on server
python manage.py runserver