Skip to content

Instantly share code, notes, and snippets.

@nigelheap
Created January 19, 2017 04:39
Show Gist options
  • Save nigelheap/9ba4bd89cfaed710697eec99a7eada31 to your computer and use it in GitHub Desktop.
Save nigelheap/9ba4bd89cfaed710697eec99a7eada31 to your computer and use it in GitHub Desktop.
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