#!/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}
mysql