Skip to content

Instantly share code, notes, and snippets.

@joinemm
Last active September 10, 2022 14:39
Show Gist options
  • Save joinemm/14d42dc7bf0187946827d9c216269b88 to your computer and use it in GitHub Desktop.
Save joinemm/14d42dc7bf0187946827d9c216269b88 to your computer and use it in GitHub Desktop.
Backup and restore data from a running mysql docker container
# 1. start the db container and map it to local port 3306
# 2. dump it (remove --no-create-info to also migrate schema)
$ mysqldump --port 3306 -h 0.0.0.0 -prootpw --no-create-info database > mydb.sql
# 3. move to another host
$ scp source:~/mydb.sql dest:~/
# 4. start db on destination
# 5. create schema if not created automatically
# 6. restore data
$ mysql --port 3306 -h 0.0.0.0 -prootpw database < mydb.sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment