DEV Community

Capwell Murimi
Capwell Murimi

Posted on

4 1 1 3 1

🚚 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

Heroku

Deploy with ease. Manage efficiently. Scale faster.

Leave the infrastructure headaches to us, while you focus on pushing boundaries, realizing your vision, and making a lasting impression on your users.

Get Started

Top comments (2)

Collapse
 
stanleymasinde profile image
Stanley Masinde

Great read

Collapse
 
capwellmurimi profile image
Capwell Murimi

Thank you

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →