zoukankan      html  css  js  c++  java
  • Shell 操作练习

    #! /bin/sh
    ###############################
    #          2013-11-19         #
    #        author jackluo       #
    #      net.webjoy@gmail.com   #
    ###############################
    serverid=$1 #服务器的id
    db_name=$2  #数据库名
    db_host=$3 #mysql 的主机地址
    databases_file_path=/home/wwwroot/cy/application/config/database.php
    db_user=root #数据库帐号
    db_password=admin #数据库密码
    db_host=localhost #数据库ip
    db_template_path=/home/jackluo/platform.sql #要导入的模板数据库
    
    if [ -z "${serverid}" ] || [ -z "${db_name}" ] || [ -z "${db_host}" ];then
        echo "参数不够 共3个参数第一个是服务器的id 第二个是数据名, 第三个是mysql的主机地址"
        exit
    fi
    echo "/***************appgame ${serverid}************/
    $db['${serverid}']['gamedb']['hostname'] = 'localhost';
    $db['${serverid}']['gamedb']['username'] = 'jack';
    $db['${serverid}']['gamedb']['password'] = '****';
    $db['${serverid}']['gamedb']['database'] = '${db_name}';
    
    $db['${serverid}']['gamedb']['dbdriver'] = 'mysql';
    $db['${serverid}']['gamedb']['dbprefix'] = '';
    $db['${serverid}']['gamedb']['pconnect'] = FALSE;
    $db['${serverid}']['gamedb']['db_debug'] = TRUE;
    $db['${serverid}']['gamedb']['cache_on'] = FALSE;
    $db['${serverid}']['gamedb']['cachedir'] = '';
    $db['${serverid}']['gamedb']['char_set'] = 'utf8';
    $db['${serverid}']['gamedb']['dbcollat'] = 'utf8_general_ci';
    $db['${serverid}']['gamedb']['swap_pre'] = '';
    $db['${serverid}']['gamedb']['autoinit'] = TRUE;
    $db['${serverid}']['gamedb']['stricton'] = FALSE;
    
    $db['${serverid}']['remotedb']['hostname'] = '${db_host}';
    $db['${serverid}']['remotedb']['username'] = 'luo';
    $db['${serverid}']['remotedb']['password'] = '***';
    $db['${serverid}']['remotedb']['database'] = '${db_name}';
    
    $db['${serverid}']['remotedb']['dbdriver'] = 'mysql';
    $db['${serverid}']['remotedb']['dbprefix'] = '';
    $db['${serverid}']['remotedb']['pconnect'] = FALSE;
    $db['${serverid}']['remotedb']['db_debug'] = TRUE;
    $db['${serverid}']['remotedb']['cache_on'] = FALSE;
    $db['${serverid}']['remotedb']['cachedir'] = '';
    $db['${serverid}']['remotedb']['char_set'] = 'utf8';
    $db['${serverid}']['remotedb']['dbcollat'] = 'utf8_general_ci';
    $db['${serverid}']['remotedb']['swap_pre'] = '';
    $db['${serverid}']['remotedb']['autoinit'] = TRUE;
    $db['${serverid}']['remotedb']['stricton'] = FALSE;
    /***************appgame ${serverid}********************/
    
    " >> ${databases_file_path} #写入数据库
    sed -i 's/
    //' ${databases_file_path} #替换^M 这样的东西
    #创建数据库
    mysql -u${db_user} -p${db_password} -h${db_host} <<EOF
        set names utf8; 
        create database ${db_name};
        use ${db_name};
        source ${db_template_path};
    EOF
  • 相关阅读:
    如何用Tensorflow训练模型成pb文件和和如何加载已经训练好的模型文件
    hbase rowkey 设计
    hbase集群region数量和大小的影响
    为什么不建议在hbase中使用过多的列簇
    hive explode 行拆列
    通过livy向CDH集群的spark提交任务
    case when多条件
    spark sql/hive小文件问题
    SQL join
    spark任务调度模式,动态资源分配
  • 原文地址:https://www.cnblogs.com/jackluo/p/3429960.html
Copyright © 2011-2022 走看看