Skip to content

Instantly share code, notes, and snippets.

@DrayChou
Created July 6, 2014 18:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DrayChou/9e342b6c5d63fe0bb209 to your computer and use it in GitHub Desktop.
Save DrayChou/9e342b6c5d63fe0bb209 to your computer and use it in GitHub Desktop.
导出数据表为XML
#!/bin/env bash
username=""
passwd=""
host=""
db1=""
#连接数据库把表都拉出来
mysql_tables=`mysql -h $host -u $username -p"$passwd" -e "use $db1; show tables; " | grep -vE "Tables_in_src_master"`
#循环把表导出为XML
for i in ${mysql_tables[@]} ; do
#导出数据表
mysqldump --xml -h $host -u $username -p"$passwd" $db1 $i | tee $db1.$i.xml
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment