Docker, PostgreSQL, Software Development

Migrate from MySQL to PostgreSQL Using Pgloader Docker Container

This post shows how to migrate a database from MySQL to a PostgreSQL instance running on Windows using the pgloader (running as a Docker container) to perform the migration from MySQL to PostgreSQL. From within the container, we use docker.for.win.localhost to refer to the host specific to Windows hosts. Alternatively, we can use host.docker.internal for non-Windows systems.

Requirements

We use the following items for this post.

  • Docker for Windows (CE) – 18.06.1-ce-win73 (19507)
  • MySQL 5.5.60 Community Edition
  • PostgreSQL 10.5
  • Windows 10 Enterprise

Sample MySQL Data To Migrate – Pgloader Source Database

Suppose we have a persons table that contains two columns – person_id and person_name.

Pgloader Target Database – PostgreSQL 10 Instance

The migration of data from MySQL to PostgreSQL requires a running PostgreSQL instance. Also, the PostgreSQL instance must have

For example, consider the following screenshot. It shows the initial PostgreSQL schema. However, it must be an empty schema to serve as a target schema for the migration. Hence, we have turretadb in PostgreSQL.

Migrate Data From MySQL to PostgreSQL Using Pgloader Docker Images

There are two Docker images that we can use to migrate data from MySQL to PostgreSQL.

Option 1, we can use dimitri/pgloader, but I have encountered a known issue that prevents the migration from completing (see the second image).

Option 2, we can use mastersland/pgloader.

Migrate from MySQL to PostgreSQL using pgloader Docker container

Verify Pgloader Migration In PostgreSQL

Migrate from MySQL to PostgreSQL using pgloader Docker container

 

Loading

Got comments or suggestions? We disabled the comments on this site to fight off spammers, but you can still contact us via our Facebook page!.


You Might Also Like