[SOLVED] Migrating database from MySQL to PostgreSQL

I am currently running Metabase using MySQL as database, and I want do migrate it to a PostgreSQL. Have anyone done this? How can I do it?

Thanks all in advance!

Hi @PabloBrenner
I’ve used pgLoader a few times and it’s worked like a treat. But I had to use the latest build instead of the release on several occasions, because there were some issues that was not yet fixed in the release. Not sure if that’s still the case, but just wanted to note it.
https://pgloader.io/
EDIT: DO has a tutorial you might want to check too:
https://www.digitalocean.com/community/tutorials/how-to-migrate-mysql-database-to-postgres-using-pgloader

1 Like

Flamber, thanks a lot for the reply!

After migrating all tables and data, for metabase for “understand” the new database will it work if I just change the MB_DB_ variables before running?

@PabloBrenner
Yes, it should Just Work™, but you should of course make backups before starting the migration and then when you start Metabase using Postgres for the first time, then you’ll want to check the logs at startup, but also during at least the first hour.
By the way, I’m guessing you’re using the latest 0.32.10 release. It’s important that you don’t try to migrate and upgrade in the same process, since it might fail or corrupt the metadata.

1 Like

Thanks a lot!

I followed these steps and this proved to be wrong,
There is no way you can migrate from mysql to postgres directly.
Here is the issue I created on github: After changing metabase database from mysql to pgsql migration checksums check fails · Issue #37101 · metabase/metabase · GitHub
you have to dump mysql to h2 and then load it into postgres