Advertisement
Guest User

Untitled

a guest
Mar 9th, 2019
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. --fields-terminated-by=name
  2. Fields in the output file are terminated by the given
  3. --lines-terminated-by=name
  4. Lines in the output file are terminated by the given
  5.  
  6. `--fields-terminated-by`
  7.  
  8. MYSQL_USER=root
  9. MYSQL_PASS=rootpassword
  10. MYSQL_CONN="-u${MYSQL_USER} -p${MYSQL_PASS}"
  11. SQLSTMT="SELECT CONCAT(table_schema,'.',table_name)"
  12. SQLSTMT="${SQLSTMT} FROM information_schema.tables WHERE table_schema NOT IN "
  13. SQLSTMT="${SQLSTMT} ('information_schema','performance_schema','mysql')"
  14. mysql ${MYSQL_CONN} -ANe"${SQLSTMT}" > /tmp/DBTB.txt
  15. COMMIT_COUNT=0
  16. COMMIT_LIMIT=10
  17. for DBTB in `cat /tmp/DBTB.txt`
  18. do
  19. DB=`echo "${DBTB}" | sed 's/./ /g' | awk '{print $1}'`
  20. TB=`echo "${DBTB}" | sed 's/./ /g' | awk '{print $2}'`
  21. DUMPFILE=${DB}-${TB}.csv.gz
  22. mysqldump ${MYSQL_CONN} --fields-terminated-by="t" --lines-terminated-by="rn" ${DB} ${TB} | gzip > ${DUMPFILE}
  23. (( COMMIT_COUNT++ ))
  24. if [ ${COMMIT_COUNT} -eq ${COMMIT_LIMIT} ]
  25. then
  26. COMMIT_COUNT=0
  27. wait
  28. fi
  29. done
  30. if [ ${COMMIT_COUNT} -gt 0 ]
  31. then
  32. wait
  33. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement