How to migrate MySQL -> PostgreSQL?

38 views
Skip to first unread message

Victor Porton

unread,
Jun 3, 2019, 3:20:59 PM6/3/19
to Django users
How to migrate a production database MySQL -> PostgreSQL?

(MySQL has several bugs, I want to try something other on my production server.)

Ankhi Roy

unread,
Jun 3, 2019, 4:03:11 PM6/3/19
to django...@googlegroups.com
Hey Victor, 

Do you mean to use postgresql instead of mysql,  if so please change database settings in settings.py. However,  I am not sure how will you migrate your existing mysql tables and contents to postgresql. Just a workaround you can recreate tables in postgresql and re add the data. There must be an efficient way though.

Thanks 
Ankhi 

On Mon, Jun 3, 2019, 8:21 PM Victor Porton <por...@narod.ru> wrote:
How to migrate a production database MySQL -> PostgreSQL?

(MySQL has several bugs, I want to try something other on my production server.)

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/97a3c018-86ee-462a-a21a-6d2a7971adc1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Kiran Capoor

unread,
Jun 3, 2019, 6:56:52 PM6/3/19
to django...@googlegroups.com
Hi, 

As said by ankhi, change to pgsql in settings before that use the django fixtures feature to take a backup of the data etc. try in test env only as this has breaking potential.

Regards,
Kiran Capoor


For more options, visit https://groups.google.com/d/optout.
--
Sent from iPhone

Julien Enselme

unread,
Jun 4, 2019, 5:16:59 AM6/4/19
to django...@googlegroups.com
Hi,

At my company we recently made a switch from MySQL to PG. We used https://pgloader.io/ to load the data from MySQL to PG. It reliable and quite fast (we had about 2GO of data to migrate in multiple table). The tool will handle table creation and data migration. As @Kiran said, try first in a test env. It may take a while depending on the amount of code that relies on MySQL specific features. I hope this helps!

Regard,
Julien Enselme
Développeur chez BureauxLocaux


Devender Kumar

unread,
Jun 5, 2019, 8:02:29 AM6/5/19
to django...@googlegroups.com
Hi,
It's very complicated with not much explanation in question. 
Its depend on where you want to do this process Development or Production.
If it is development then and not holding a very large amount of data.
then its not very complicated
 dump JSON > change database engine > load JSON.
If its production end then you might have to write some scripts to copy data from one database (MySQL) to dump Into another database (PostgreSQL) in between you can use transition state of JSON OR XML 

Thank you


phep

unread,
Jun 5, 2019, 9:53:48 AM6/5/19
to django...@googlegroups.com
Hi,

Would you mind giving details why dumping/reloading JSON should not be used
in production (putting aside HA problems, for sure).

TIA

Le 05/06/2019 à 14:01, Devender Kumar a écrit :
> Hi,
> *It's very complicated with not much explanation in question.*
> Its depend on where you want to do this process Development or Production.
> If it is development then and not holding a very large amount of data.
> then its not very complicated
>  dump JSON > change database engine > load JSON.
> If its production end then you might have to write some scripts to copy data
> from one database (MySQL) to dump Into another database (PostgreSQL) in
> between you can use transition state of JSON OR XML
>
> Thank you
>
>
> On Tue, Jun 4, 2019 at 2:46 PM Julien Enselme
> <julien....@bureauxlocaux.com <mailto:julien....@bureauxlocaux.com>>
> wrote:
>
> Hi,
>
> At my company we recently made a switch from MySQL to PG. We used
> https://pgloader.io/ to load the data from MySQL to PG. It reliable and
> quite fast (we had about 2GO of data to migrate in multiple table). The
> tool will handle table creation and data migration. As @Kiran said, try
> first in a test env. It may take a while depending on the amount of code
> that relies on MySQL specific features. I hope this helps!
>
> Regard,
> Julien Enselme
> Développeur chez BureauxLocaux
>
>
> Le mar. 4 juin 2019 à 00:56, Kiran Capoor <kiranc...@gmail.com
> <mailto:kiranc...@gmail.com>> a écrit :
> <mailto:django-users...@googlegroups.com>.
> To post to this group, send email to
> django...@googlegroups.com
> <mailto:django...@googlegroups.com>.
> <https://groups.google.com/d/msgid/django-users/97a3c018-86ee-462a-a21a-6d2a7971adc1%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the
> Google Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from
> it, send an email to django-users...@googlegroups.com
> <mailto:django-users...@googlegroups.com>.
> To post to this group, send email to
> django...@googlegroups.com
> <mailto:django...@googlegroups.com>.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CABUQWg_hm7U__cwKJvFvvvR3osuz-MtswCL1YLA74pGdEvp_PA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CABUQWg_hm7U__cwKJvFvvvR3osuz-MtswCL1YLA74pGdEvp_PA%40mail.gmail.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.
>
> --
> Sent from iPhone
>
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to django-users...@googlegroups.com
> <mailto:django-users...@googlegroups.com>.
> To post to this group, send email to django...@googlegroups.com
> <mailto:django...@googlegroups.com>.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAANvM2%3DHjGDSL3_rX6adnkp-8o%2Bj9trx9as0AMC5VGpMw25nZA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAANvM2%3DHjGDSL3_rX6adnkp-8o%2Bj9trx9as0AMC5VGpMw25nZA%40mail.gmail.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users...@googlegroups.com
> <mailto:django-users...@googlegroups.com>.
> To post to this group, send email to django...@googlegroups.com
> <mailto:django...@googlegroups.com>.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAL%3D_h26ttWeRZ5cv4dADrmLg4upJC65zdg4%3Dw1GFc8qZLUU5nw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAL%3D_h26ttWeRZ5cv4dADrmLg4upJC65zdg4%3Dw1GFc8qZLUU5nw%40mail.gmail.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users...@googlegroups.com
> <mailto:django-users...@googlegroups.com>.
> To post to this group, send email to django...@googlegroups.com
> <mailto:django...@googlegroups.com>.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CALZ%3DbEKFvRFucvU-LeMCR4ejLska64zGKjq0m_hhoRYxJxyZHw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CALZ%3DbEKFvRFucvU-LeMCR4ejLska64zGKjq0m_hhoRYxJxyZHw%40mail.gmail.com?utm_medium=email&utm_source=footer>.

Devender Kumar

unread,
Jun 6, 2019, 7:15:34 AM6/6/19
to Django users
Simple scripts :
Dump data 
python manage.py dumpdata  # this will whole database to single json 
python manage.py loaddata filename # this will populate the database with that json again 
Reply all
Reply to author
Forward
0 new messages