Sept. 7, 2021, 7:35 p.m.
Complete process of changing database from SQLite to MySQL - How to migrate a Django DB from SQLite to MySQL
Here are some advantages & disadvantages of using SQLITE :
Advantages :
1) Sqlite is Lightweight.
2) No Installation Needed.
3) Portable & reliable
Disadvantages :
1) SQLite is used to handle low to medium traffic.
2) Database size is restricted upto 2GB (in most cases).
Today i will show you how you can migrate db from SQLITE to MySQL in 6 simple steps. Just bare with me & i will provide the easiest way to do stuff in right manner.
Step 1 First of all make a zip file of your whole website folder for backup security purpose (highly recommended).
Now, we have to dump all data from SQlite in a json file. For this purpose we have to use the following command.
python manage.py dumpdata > datadump.json
Just go to the working directory (in the virtual environment) and run the above command. The execution may takes time depends upon database size.
Please try ,not to close console untill the final step.
Step 2 Now install mysqlclient by using following command. This is nothing but a connector for python with mysql.
pip install mysqlclient
Step 3 Now you have make some changes in settings.py file. Search for a dictionary named as "DATABASES" and replace it with the following code.
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'Database_name',
'USER': 'Username',
'PASSWORD': 'db_password',
'HOST': 'mysql_host_name',
'PORT': '3306',
'OPTION': {'init_command': 'set storage_engine=InnoDB; \
set session transaction isolation level read committed'},
}}
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'Database_name',
'USER': 'Username',
'PASSWORD': 'db_password',
'HOST': 'mysql_host_name',
'PORT': '3306',
'OPTION': {'init_command': 'set storage_engine=InnoDB; \
set session transaction isolation level read committed'},
}}
Make sure you can connect on your mysql DB (permissions,etc) i.e check the details carefully before proceeding.
Note that the OPTION may have more parameters. You can check the django documentation for more values, but if you keep it as it is above there will be no issue.

python manage.py migrate --run-syncdb
You can ignore the warnings that pop-ups in console (if any) 
Exclude contentype data with this snippet in shell.
python manage.py shell
from django.contrib.contenttypes.models import ContentType
ContentType.objects.all().delete()
quit()
from django.contrib.contenttypes.models import ContentType
ContentType.objects.all().delete()
quit()

python manage.py loaddata datadump.json
Tips If you face any problem for example if you have any app like sorl-thumbnail or easy-thumbnail in your INSTALLED_APPS ,sometimes a file(thumbnail) is not present in media files which makes the last step incomplete. The point is if you face any issue just read the error location and the app/module which is causing error. Then replace the website data from our back-up file(that is why i recommended to make a backup zip file of whole website) and remove that app from INSTALLED_APPS (run migrate command if required).
Now you have to perform all the steps again.
Some recent posts
How to deploy a django website on pythonanywhere | django Web app deploying...
Complete process of changing database from SQLite to MySQL - How to migrat...
" How to download a file in django | Making a large file downloadable from ...
How to use proxy in python requests | http & https proxies - Scraping...
Top Django Querysets, How to filter records | Fetching data from database e...
How to change base url or domain in sitemap - Django ...
How to Make a Website - Everything you should know about web development...
What is Javascript - Features and usages ...
Top 5 Interview Questions : Tips for HR round ...
How to get job in IT : Perfect resume guide for IT job ...
View all...
Popular Posts
How to compress image before saving to DBMigrating from SQLite to MySQL in Django
Choosing correct M.2 SSD
How to deploy a web app on pythonanywhere
5 Steps to create sitemap in Django
How to send mails automatically in Django
Handling arguments in django urls
Media and Static configuration in Django
Language Translation & detection using python
React Js vs Angular Js
5 Tips to improve Programming Logics