• shell脚本的小记


    作者:邓聪聪

    mysql的脚本执行

    #!/bin/sh
    HOST="127.0.0.1"
    PORT="3306"
    UESRNAME="root"
    PASSWORD="123456"
    
    #DB_NAME="day1"
    #DB_NAME="day2"
    DB_NAME="day3"
    TABLE_NAME="logs"
    
    log=1.txt
    #task.log=result.log
    exec 2>>$log
    exec 1>>$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 [ $? == 0 ];
    then
            echo "任务完成"
    else
            echo "任务失败"
    fi
  • 相关阅读:
    判断质数
    猜拳三局两胜
    输入年月日判断是这一年的哪一天
    switch case
    猜拳
    判断年月日是否正确
    老狼老狼几点了
    判断是否中奖
    平滑部署war包到tomcat-deploy.sh
    只用120行Java代码写一个自己的区块链-3挖矿算法
  • 原文地址:https://www.cnblogs.com/dengcongcong/p/10250054.html
Copyright © 2020-2023  润新知