Forked from iamcryptoki/export-restore-kubernetes-mysql-database.txt
Created
July 9, 2021 07:31
-
-
Save perfectfoolish/da284cac43aedf760990cc0049f98097 to your computer and use it in GitHub Desktop.
Export MySQL database from Kubernetes pod.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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