Quantcast
Channel: migrating to mysql in django - Stack Overflow
Viewing all articles
Browse latest Browse all 3

Answer by Micha Fellner for migrating to mysql in django

$
0
0

I had to move my database from a postgres to a MySql-Database.

This worked for me:

Export (old machine):

python manage.py dumpdata --natural --all --indent=2 --exclude=sessions  --format=xml > dump.xml

Import (new machine):(note that for older versions of Django you'll need syncdb instead of migrate)

manage.py migrate --no-initial-data

Get SQL for resetting Database:

manage.py sqlflush

setting.py:

DATABASES = {'default': {'ENGINE': 'django.db.backends.mysql','NAME': 'asdf','USER': 'asdf','PASSWORD': 'asdf','HOST': 'localhost',    #IMPORTANT!!'OPTIONS': {"init_command": "SET foreign_key_checks = 0;",        },}python manage.py loaddata dump.xml

Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>