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]#

  • 相关阅读:
    03server
    Storm介绍(一)
    storm总结
    Spring源码分析(七)扩展接口BeanPostProcessors源码分析
    技术大牛养成指南
    02装配bean
    02Activity
    maven构建项目
    IDEA使用
    从GIt上导出Maven项目
  • 原文地址:https://www.cnblogs.com/rsapaper/p/8034840.html
Copyright © 2011-2022 走看看