-
-
Save CmdrMahesh/2f95dd7bd30283da390ce8a869bcd7c0 to your computer and use it in GitHub Desktop.
Small script to dump all local mysql databases
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
#!/usr/bin/env python | |
import os | |
import re | |
import subprocess | |
user="onlyme" | |
password="xxxxxxx" | |
proc = subprocess.Popen(["mysql", "-u" + user, "-p" + password], | |
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr = subprocess.PIPE) | |
output, errors = proc.communicate("SHOW DATABASES") | |
for database in output.splitlines()[1:]: | |
if database != 'information_schema': | |
print "Dumping %s" % database | |
file = open("%s.sql" % database, 'w') | |
proc = subprocess.Popen(["mysqldump", "-u" + user, "-p" + password, database], | |
stdout=file) | |
proc.communicate() | |
file.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment