Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

lat4732's avatar
Level 12

Migrating from MySQL to PostgreSQL

Hello everyone! I'm currently running a project on MySQL and Laravel 8. I want to switch from MySQL to PostgreSQL without losing any information from my current database. How can I transfer everything to PostgreSQL and in general how to switch to PostgreSQL?

0 likes
12 replies
sr57's avatar
sr57
Best Answer
Level 39

Here https://dbconvert.com/mysql/postgresql/ you can find good information.

As written "Transferring data between two different management systems is not a trivial task. "

Laravel use mainly "common functionnalities" between both DBMS, so the best way to try first, is to save your project, change (in .env) the DB type et remigrate everything, it should work if you don't use MySql specific (personnaly I always use Postgresl)

1 like
lat4732's avatar
Level 12

@sr57 This did not help me in any way. It doesn't answer my question of how to transfer everything without losing anything from my current MySQL database.

Sinnbeck's avatar

@LarAlex How is that not helpful? There is a link for a tool that can do the work for you? If you scroll down half way on the page, there is even a step by step guide?

lat4732's avatar
Level 12

@Sinnbeck How is that helpful? Paying either 150 or 600 bux to convert MySQL database to PostgreSQL?

lat4732's avatar
Level 12

@Sinnbeck I can not find adequate documentation of pgloader how to use it. Maybe you can help me up how to set it up?

lat4732's avatar
Level 12

@Sinnbeck Does this "load" file have some kind of structure? I'm so confused reading this documentation. I understand what I need to build in this file, but what is the structure behind it? First, what is actually mysql://root@localhost/sakila is that some endpoint URL or what?

Sinnbeck's avatar

So you went with DBConvert or DBSync ? That is probably a bit easier to set up as well :)

sr57's avatar

@laralex @sinnbeck Sorry to have give more explanation after my first answer, I was out all the day.

@sinnbeck Thanks to have given more precise info.

@laralex You finally use my first answer because it's probably the easiest and don't totally understand my 2nd line. Laravel let you create compatible db between mysql/mariadb and postgresql. After it's only to chose the way to transfer the data, and depending the nb of tables, volume, one shot or not, ... you can chose different solution (DB Convert, via .csv export/import, via 2 connections on on Laravel App, ... ) Last but not least, postgresql tools that are very good in general ... to be discovered by your future use of postgresql.

2 likes

Please or to participate in this conversation.