DEV Community

Capwell Murimi
Capwell Murimi

Posted on

๐Ÿšš One-Time MySQL to PostgreSQL Migration with pgloader + Docker (Windows-Friendly)

Hey folks ๐Ÿ‘‹ Iโ€™m Capwell, and I recently had to migrate a MySQL database to PostgreSQL. It wasnโ€™t a continuous sync โ€” just a one-time migration โ€” so I needed a quick, clean way to do it.

When youโ€™re on Windows,You donโ€™t want to install a bunch of tools, and just need something that works without drama, it can feel like a puzzle.

Thatโ€™s what led me to pgloader + Docker โ€” the perfect combo for a painless one-time migration. No native installs, no environment weirdness. Just results.

Hereโ€™s how I made it work

Installing Docker on Windows
If youโ€™re using Windows (like I was), the easiest way to get started is by installing Docker Desktop. Hereโ€™s a quick walkthrough:

Download Docker Desktop
๐Ÿ‘‰ Docker

Run the Installer
Follow the setup wizard. Youโ€™ll need WSL enabled (Windows Subsystem for Linux), which Docker will guide you through if itโ€™s not already installed.

Launch Docker
Once installed, launch Docker Desktop. You should see the Docker whale icon in your system tray.

Why pgloader?
pgloader is an open-source tool that:

โœ… Migrates schema and data
โœ… Handles type conversions
โœ… Works with MySQL, SQLite, MS SQL
โœ… Supports load scripts for reusable, declarative migrations
โœ… Can be run with Docker โ€” no need to install anything

Step 1: Create a pgloader Load Script
In the folder where you want to run the migration, create a file called mysql_to_pg.load with the following content:

LOAD DATABASE FROM mysql://root:yourpass@host.docker.internal/source_db INTO postgresql://postgres:pgpass@host.docker.internal/target_db WITH include drop, create tables, create indexes, reset sequences, data only SET work_mem to '16MB', maintenance_work_mem to '512 MB'; ALTER SCHEMA 'source_db' RENAME TO 'public'; 
Enter fullscreen mode Exit fullscreen mode

๐Ÿ” Replace:

yourpass โ†’ your MySQL root password

pgpass โ†’ your PostgreSQL password

source_db / target_db โ†’ your actual DB names

Step 2: Run pgloader with Docker
Make sure Docker is installed and both MySQL/PostgreSQL are up and running.

On Windows (PowerShell)
powershell

docker run --rm -v "folder where the file is":/mnt dimitri/pgloader pgloader /mnt/mysql_to_pg.load

๐Ÿ›  Common Pitfalls
โœ… Make sure MySQL and Postgres are running

โœ… Ensure firewall/ports arenโ€™t blocking connections

โœ… For Dockerized MySQL/Postgres, use a shared network or proper host IPs

๐Ÿ’ฌ Final Thoughts
This approach:

โœ”๏ธ Works on Windows (which I used)
โœ”๏ธ Doesnโ€™t require any installs (thanks to Docker)
โœ”๏ธ Makes migrations repeatable with load scripts

For a one-time migration, it's hard to beat.

Got stuck?
Drop a comment below or ping me on Twitter

Top comments (2)

Collapse
 
stanleymasinde profile image
Stanley Masinde

Great read

Collapse
 
capwellmurimi profile image
Capwell Murimi

Thank you