zoukankan      html  css  js  c++  java
  • shell 读写远程数据库

    http://www.cnblogs.com/wangkangluo1/archive/2012/04/27/2472898.html

    利用Shell脚本实现远程MySQL自动查询

    目的:对定时任务对数据库的读写结果,通过定时脚本进行监控,实时数据通过浏览器或定时脚本展现

    yum install mysql

    mysql -u$user -p$pass -h$ip -P$port $db_name (注意 -u和用户名之间没有空格)

    http://www.jb51.net/article/39242.htm

    利用Shell脚本实现远程MySQL自动查询

    [root@hadoop1 bash_app]# vim mysql.domo.sh
    [root@hadoop1 bash_app]# chmod a+x mysql.domo.sh
    [root@hadoop1 bash_app]# ll -as
    总用量 8
    0 drwxr-xr-x 2 root root   26 12月 19 10:37 .
    4 drwxr-xr-x 5 root root 4096 12月 19 10:23 ..
    4 -rwxr-xr-x 1 root root  268 12月 19 10:37 mysql.domo.sh
    [root@hadoop1 bash_app]# ./mysql.domo.sh
    COUNT(1) 177242
    [root@hadoop1 bash_app]# ./mysql.domo.sh  >> db_sh_output
    [root@hadoop1 bash_app]# ./mysql.domo.sh  >> db_sh_output
    [root@hadoop1 bash_app]# cat db_sh_output
    COUNT(1) 177237
    COUNT(1) 177237
    [root@hadoop1 bash_app]# cat mysql.domo.sh
    HOST=sql.rds.iyuncs.com
    PORT=3306
    USER=teon
    PASS=t@j2I
    DB=dit_aid
    QUERY=`mysql -h$HOST -P$PORT -u$USER -p$PASS $DB << EOF
    SELECT COUNT(1)  FROM order WHERE   unix_timestamp(now())< expire_time;;
    exit
    EOF`
    echo $QUERY
    [root@hadoop1 bash_app]#

  • 相关阅读:
    AWK 学习手札之一: an AWK tutorial
    SQL语句教程学习笔记之一
    c#支付宝支付
    table隔行变色
    读取接口
    倒计时
    新建的mvc项目运行之后报错找不到页面
    sql向表中添加字段
    取小数点后面几位数
    H5拨打电话
  • 原文地址:https://www.cnblogs.com/rsapaper/p/8034840.html
Copyright © 2011-2022 走看看