Created
January 19, 2017 04:39
-
-
Save nigelheap/9ba4bd89cfaed710697eec99a7eada31 to your computer and use it in GitHub Desktop.
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
MYSQL_USER=root | |
MYSQL_PASS=root | |
MYSQL_CONN="-u${MYSQL_USER} -p${MYSQL_PASS}" | |
# | |
# Collect all database names except for | |
# mysql, information_schema, and performance_schema | |
# | |
SQL="SELECT schema_name FROM information_schema.schemata WHERE schema_name NOT IN" | |
SQL="${SQL} ('mysql','information_schema','performance_schema')" | |
DBLISTFILE=/tmp/DatabasesToDump.txt | |
mysql ${MYSQL_CONN} -ANe"${SQL}" > ${DBLISTFILE} | |
mkdir dbs | |
for DB in `cat ${DBLISTFILE}`; | |
do | |
echo "Dumping ${DB}"; | |
/Applications/MAMP/Library/bin/mysqldump ${MYSQL_CONN} --databases ${DB} > dbs/${DB}.sql; | |
echo "Dumped ${DB}"; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment