Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save perfectfoolish/da284cac43aedf760990cc0049f98097 to your computer and use it in GitHub Desktop.
Save perfectfoolish/da284cac43aedf760990cc0049f98097 to your computer and use it in GitHub Desktop.
Export MySQL database from Kubernetes pod.
# Export dump particular database.
$ kubectl exec {{podName}} -n {{namespace}} -- mysqldump -u {{dbUser}} -p{{password}} {{DatabaseName}} > <scriptName>.sql
# Export dump all databases.
$ kubectl exec {{podName}} -n {{namespace}} -- mysqldump -u {{dbUser}} -p{{password}} --all-databases > <scriptName>.sql
# Restore a database from a dump.
$ kubectl exec -it {{podName}} -n {{namespace}} -- mysql -u {{dbUser}} -p{{password}} {{DatabaseName}} < <scriptName>.sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment