shell脚本的小记

作者:邓聪聪

mysql的脚本执行

#!/bin/sh
HOST="127.0.0.1"
PORT=""
UESRNAME="root"
PASSWORD="" #DB_NAME="day1"
#DB_NAME="day2"
DB_NAME="day3"
TABLE_NAME="logs" log=.txt
#task.log=result.log
exec >>$log
exec >>$log creat_db_sql="create database if not exists ${DB_NAME}"
creat_table_sql="create table IF not exists ${TABLE_NAME} ( name varchar(20), id int(23) primary key auto_increment )"
insert_sql="insert into ${TABLE_NAME} values('billchen',2)"
select_sql="select * from ${TABLE_NAME}"
update_sql="update ${TABLE_NAME} set id=3"
delete_sql="delete from ${TABLE_NAME}" #creat_db_sql="create database if not exists ${DB_NAME}"
mysql -h${HOST} -u${UESRNAME} -p${PASSWORD} -e "${creat_db_sql}" #creat_table_sql="create table if not exists ${TABLE_NAME} ( name varchar(20), id int(11) default 0 auto_increment=1)"
mysql -h${HOST} -u${UESRNAME} -p${PASSWORD} -D ${DB_NAME} -e "${creat_table_sql}" #insert_sql="insert into ${TABLE_NAME} values('billchen',2)"
mysql -h${HOST} -u${UESRNAME} -p${PASSWORD} ${DB_NAME} -e "${insert_sql}" #select_sql="select * from ${TABLE_NAME}"
mysql -h${HOST} -u${UESRNAME} -p${PASSWORD} ${DB_NAME} -e "${select_sql}" mysql -h${HOST} -u${UESRNAME} -p${PASSWORD} ${DB_NAME} -e "${update_sql}" mysql -h${HOST} -u${UESRNAME} -p${PASSWORD} ${DB_NAME} -e "${delete_sql}" if [ $? == ];
then
echo "任务完成"
else
echo "任务失败"
fi
上一篇:Python实现删除文件夹内规定时间内的文件


下一篇:unity 解决ScrollRect嵌套滚动问题