Shell查询MySQL

#!/bin/bash
host=172.10.10.10
port=3306
username=test
password=web123

#sql
cmd="./mysql-5.7/bin/mysql -h$host -P$port -u$username -p$password --default-character-set=utf8 -A -N"
sql="select id,taskid from test_common_test.log where id=1978"

ret=`$cmd -e "$sql"`
echo $ret

你可能感兴趣的:(Shell查询MySQL)