#!/bin/bash
HOST_NAME="localhost"
PORT=3306
USERNAME="root"
PASSWORD="root"
DBNAME="test"
TABLENAME="tb_test"
today=`date +%Y-%m-%d`
#删除数据
delete_sql="delete from ${TABLENAME} where todaytime!= '${today}'"
mysql -h${HOST_NAME} -P${PORT} -u${USERNAME} -p${PASSWORD} ${DBNAME} -e "${delete_sql}"
HOST_NAME="localhost"
PORT=3306
USERNAME="root"
PASSWORD="root"
DBNAME="test"
TABLENAME="tb_test"
today=`date +%Y-%m-%d`
#删除数据
delete_sql="delete from ${TABLENAME} where todaytime!= '${today}'"
mysql -h${HOST_NAME} -P${PORT} -u${USERNAME} -p${PASSWORD} ${DBNAME} -e "${delete_sql}"
版权声明:本文博主原创文章,博客,未经同意不得转载。