shell脚本操作数据库

时间:2024-05-03 13:06:08

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

版权声明:本文博主原创文章,博客,未经同意不得转载。