Skip to content

Convert from MySQL with Docker installation

Alex Bender edited this page Sep 11, 2017 · 3 revisions

MySQL to PSQL via Docker installation

Get the IP address of your host from the docker container:

Run command docker run -it --rm alpine /sbin/ip route|awk '/default/ { print $3 }'
That'll give you ip address of the host. Probably it'll be 172.17.0.1
The alpine image will be downloaded to your host, and if it isn't needed for you after database migration just remove it:
docker rmi alpine.

Allow remote access to mysql server:

Find mysqld.cnf file invoking locate mysqld.cnf command.
You'll get a line or few lines with paths to the configuration file. For example this one: /etc/mysql/mysql.conf.d/mysqld.cnf.
Open this file with editor, find a line contains bind-address and change it to *.
Restart mysql server via systemctl restart mysql.
Also check PRIVILEGES for the desired user-database-table triad (Command SHOW GRANTS FOR 'username'@'hostname'; can help you.

Allow remote access to psql server:

For Psql version 9.5 check the file /etc/postgresql/9.5/main/postgresql.conf. You can find it with locate command as well.
Open this file and change the listen_addresses to *.
Locate pg_hba.conf file and edit it:
Add line host all all <host-ip>/16 trust to the end of file and restart the server:
systemctl restart postgresql.service

Now it's possible to launch pgloader:
docker run --security-opt seccomp=unconfined --rm --name pgloader dimitri/pgloader:latest pgloader mysql://user:pass@<host-ip>/dbname postgresql://user:pass@<host-ip>/dbname

Clone this wiki locally