#!/bin/sh
# shell中调度执行mysql命令

#定义信息
mysql_host="192.168.1.1"
mysql_user="appuser"
mysql_passwd="123456"
DB_name="hainan"
TABLE_name="users"
username="***"

#开始执行(mysql命令最好写全路径)
/usr/bin/mysql -u${mysql_user} -h${mysql_host} -p${mysql_passwd} -e "delete from ${DB_name}.${TABLE_name} where username='${username}';"

#注意,下面的用法不行,-e不支持变量
del_sql="delete from ${DB_name}.${TABLE_name} where username='${username}';"
/usr/bin/mysql -u${mysql_user} -h${mysql_host} -p${mysql_passwd} -e ${del_sql}