I'm trying to migrate all of the data in my SQLite database to a new MySQL database, to do so, I've been following the following steps (which I found in another question What's the best way to migrate a Django DB from SQLite to MySQL?). I've tried the following approaches:
- First I run a
py manage.py dumpdata > datadump.json
. Then, I change my settings.py file to use my new MySQL database. After that, I run apy manage.py migrate --run-syncdb
And then I exclude contentType data by:
And Lastly, I try to run apython manage.py shell from django.contrib.contenttypes.models import ContentType ContentType.objects.all().delete() quit()
py manage.py loaddata datadump.json
- I've also tried to just run
py manage.py dumpdata --exclude contenttypes --exclude auth.permission --exclude sessions --indent 2 > dump.json
, followed bypy manage.py loaddata dump.json
.
The problem is that, in both approaches, in the very last step, when I'm trying to load the data into my new database, the following error is raised:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte
I've been trying to investigate what could prevent or fix this error but nothing has come up. Any help is appreciated. Thanks in advance.
In case this is needed, this is how I setup my DB in my Django Project.
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'naturalfitness_db',
'USER': 'root',
'PASSWORD': config('DB_PASSWORD'),
'HOST': 'localhost',
'PORT': '3306',
}
}
And my database already has all the tables needed to comply with all the models in my Django project.