Migrating From MySQL To PostgreSQL in Five Simple Steps
There are many reasons you may want to migrate from MySQL to PostgreSQL, which we will skip over for brevity. I see many questions about moving tables and data, and sadly, the answers range from sloppy to incredibly complicated. Each database migration is unique, as issues range from heavily relying on a vendor's feature to extremely complex schemas that require attention to minute detail.
Step 1
This may seem obvious, but the first step is access to the original 'source' database. You will need FULL admin access to the database. If you do not have full access for security, administrative, or other reasons, you will most likely not receive all the desired data.
We will use DBeaver Enterprise to connect to the source database.
![]() |
| We need to choose a MySQL database driver |
![]() |
| Configure the connection |
![]() |
| We will be porting the World database. |
In this example, we will port the MySQL World database. This dataset has been used for decades in MySQL documentation, training, and examples. You probably installed it when you installed MySQL, and it is a good example for you to experiment with on your own.
Step 2
You need to connect to the 'target' database. Again, you will need those administrative access rights.
Step 3
You need to highlight the tables you want and use Export Data
![]() |
| Pick the desired tables. |
![]() |
| Pick the target transfer type, in this case, a database. |
![]() |
| We are using a PG 17 instance. |
There are options for the extraction and loading. Stick to the defaults until you become familiar with them.
![]() |
| There are options for the extraction; use the defaults. |
![]() |
| And options for the loading; again, use the defaults. |
Now, you can back out at this point. But we want to convert, so proceed.
![]() |
| The moment of truth! |
![]() |
| And now we have the World data in PostgreSQL. |
Step 4
We can now use DBeaver to compare the data.
![]() |
| Did we get all the data? |
![]() |
| You can compare differences side by side. But in this case, there were no differences. And that is what we wanted! |
Step 5
Now you get to decide on indexes. PostgreSQL is much richer in index choices, and you can explore them at your leisure.
Remember, the hard work has been done for you. And you can use the MySQL index creation code if you want to stick with B+ Tree indexes.
Bonus
For those who feel that five steps are too many, there is a 'migrate/compare' option that we can cover later, which reduces the steps. This blog entry was created to demonstrate clear, orthogonal steps, so I did not use this option, hoping that extra clarity would be worth the extra step.
Conclusion
DBeaver is a fantastic database tool. It is handy when you have to move between versions or vendors. You can use it to change data types on the fly. The ability to move and compare data afterward gives you confidence. BTW, you can get a free two-week trial on any version by simply asking.
If you are moving from the Dolphin to the Elephant, please follow the above steps.













Comments
Post a Comment