How to export and import a MySQL database running on Docker

// copy the “CONTAINER ID”
docker ps
// 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
// copy the “CONTAINER ID”
docker ps
// 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

--

--

--

Senior Java Developer with 15 years of professional experience | Startup enthusiast.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

3 Important Things To Learn In Html5 and Css3

We moved an old Symfony 2 app from PHP 5.6 to PHP 7.1

How to setup an AWS VPC, NAT Instance and Domain Controller from scratch via the Command Line…

“CORONA VIRUS!! S#1TS GETTING REAL” — Cardi B Austin Coding Academy

Write your first Web Scraper in Dart

Is AWS vague about its products?

Conceptualization of a Data Migration I

CS373 Spring 2021: Blog#2

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
czetsuya

czetsuya

Senior Java Developer with 15 years of professional experience | Startup enthusiast.

More from Medium

Django ORM(Object–relational mapping) ‘OR’ and ‘AND’ query

MySQL/MyBatis | Using Dynamic Query

Hosting multiple containerized websites on a single server

hbase, zookeeper, sqoop, mysql Installation on Windows WSL 2 on Ubuntu 20.04 LTS (Single Node)