vi dumpdata.sh 脚本内容如下
dbname=$1
echo "当前数据库为:$1"
for i in $(mysql -uroot -p123456 -hlocalhost -e "use $dbname;show tables" 2> /dev/null|tail -n +2)
do
mysqldump -uroot -p123456 -hlocalhost --no-create-info --insert-ignore --databases $dbname --tables $i --where=" 1=1 limit 1000 " >> /data/mysql.sql
echo "success"
done
no-create-info 不执行建表语句
insert-ignore 使用insert ingnore into
--where 过滤条件
执行命令
chmod +x dumpdata
./dumpdata.sh mysql