Guest User

Untitled

a guest
Dec 24th, 2018
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. MYSQL_HOST=127.0.0.1
  4. MYSQL_USER=root
  5. MYSQL_PASS='123456'
  6. MYSQL_CONN="-h${MYSQL_HOST} -u${MYSQL_USER} -p${MYSQL_PASS}"
  7. #
  8. # Collect all database names except for
  9. # mysql, information_schema, and performance_schema
  10. #
  11. SQL="SELECT schema_name FROM information_schema.schemata WHERE schema_name NOT IN"
  12. SQL="${SQL} ('mysql','information_schema','performance_schema')"
  13.  
  14. DBLISTFILE=/tmp/DatabasesToDump.txt
  15. mysql ${MYSQL_CONN} -ANe"${SQL}" > ${DBLISTFILE}
  16.  
  17. DBLIST=""
  18. for DB in `cat ${DBLISTFILE}` ; do DBLIST="${DBLIST} ${DB}" ; done
  19.  
  20. MYSQLDUMP_OPTIONS="--skip-lock-tables --single-transaction --flush-logs --hex-blob --master-data=2"
  21. mysqldump ${MYSQL_CONN} ${MYSQLDUMP_OPTIONS} --databases ${DBLIST} > all-dbs.sql
Add Comment
Please, Sign In to add comment