#!/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}"
shell脚本操作数据库
时间: 2024-10-08 18:41:02