批量查询sql脚本
Posted 运维搬砖
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了批量查询sql脚本相关的知识,希望对你有一定的参考价值。
远程批量查询sql脚本
for i in {1..50}
do
sql_ip=172.168.0.${i}
information=`mysql -h ${sql_ip} -uroot -ppassword dbname -e ‘select name,value from setting where name = "name" UNION select name,value from setting where name = "code" ‘ |grep -v val
ue|awk -F ‘ ‘ ‘{print $2}‘|awk -F ‘\\‘ ‘{print $3}‘`
echo ${information} > information.txt
code=`cat information.txt`
token_tab=`mysql -h ${sql_ip} -uroot -ppassword dbname -e ‘select name,value from setting where name = "token"‘|grep -v value|awk -F ‘\\‘ ‘{print $3}‘`
echo ${token_tab} > token_file.txt
sed ‘s/0//g‘ token_file.txt > token.txt
token=`cat token.txt`
echo "${token} this name is "${code}"" >> integ.txt
done
以上是关于批量查询sql脚本的主要内容,如果未能解决你的问题,请参考以下文章