linux -mysql-shell脚本写入数据库

用shell脚本在mysql表中批量插入数据的方法

#!/bin/bash

i=1;
MAX_INSERT_ROW_COUNT=$1;
while [ $i -le $MAX_INSERT_ROW_COUNT ]
do
    mysql -uroot -proot afs -e "insert into afs_test (name,age,createTime) values ('HELLO$i',$i % 99,NOW());"
    d=$(date +%M-%d\ %H\:%m\:%S)
    echo "INSERT HELLO $i @@ $d"   
    i=$(($i+1))
    sleep 0.05
done

exit 0;

sh create-data.sh 10000

猜你喜欢

转载自blog.csdn.net/hao_wujing/article/details/89922838