Advertisement
Guest User

Untitled

a guest
Jan 18th, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. MYSQL_USER=root
  2. MYSQL_PASS=root
  3. MYSQL_CONN="-u${MYSQL_USER} -p${MYSQL_PASS}"
  4. #
  5. # Collect all database names except for
  6. # mysql, information_schema, and performance_schema
  7. #
  8. SQL="SELECT schema_name FROM information_schema.schemata WHERE schema_name NOT IN"
  9. SQL="${SQL} ('mysql','information_schema','performance_schema')"
  10.  
  11. DBLISTFILE=/tmp/DatabasesToDump.txt
  12. mysql ${MYSQL_CONN} -ANe"${SQL}" > ${DBLISTFILE}
  13.  
  14. mkdir dbs
  15.  
  16. for DB in `cat ${DBLISTFILE}`;
  17. do
  18. echo "Dumping ${DB}";
  19. /Applications/MAMP/Library/bin/mysqldump ${MYSQL_CONN} --databases ${DB} > dbs/${DB}.sql;
  20. echo "Dumped ${DB}";
  21. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement