no

How to Export and Import a Mysql Database Running on Docker

This series of commands serve as a guide in migrating a MySQL database from one docker instance to another. 1. Computer where source MySQL d...

This series of commands serve as a guide in migrating a MySQL database from one docker instance to another.

1. Computer where source MySQL database server is running on docker.

1.1 Get the container id of the docker instance where the MySQL source server is running.

// copy the "CONTAINER ID"
>docker ps

1.2 Export the MySQL database.

// Change the "CONTAINER ID", PASSWORD, and DATABASE values
// Note that it will create a db-dump.sql file in the folder where the command is run
>docker exec "CONTAINER ID" /usr/bin/mysqldump -u root --password=PASSWORD DATABASE > db-dump.sql

2. Computer where target MySQL database server is running on docker.

2.1 Get the container id of the docker instance where the MySQL target server is running.

// copy the "CONTAINER ID"
>docker ps

2.2 Import the MySQL database.

// Change the "CONTAINER ID", PASSWORD, and DATABASE values
// Note that it will it need a db-dump.sql file in the folder where the command will be run run
cat db-dump.sql | docker exec -i "CONTAINER ID" /usr/bin/mysql -u root --password=PASSWORD DATABASE

Related

rbdms 4273922487623180028

Post a Comment Default Comments

item