shell脚本中执行mysql命令
2015-03-31 18:57
573 查看
1.mysql -hhostname -uuser -ppsword -e "mysql_cmd"
2.
mysql -hhostname -uuser -ppsword << EOF
mysql_cmd
EOF
如下简单例子:
#!/bin/bash
mysql -hservicedb-online -uroot -proot123 -e "use test;select * from tests;" #方法1实例
mysql -hservicedb-online -uroot -proot123 << EOF #方法2实例
use test;
select * tests;
EOF
mobile_t=`/usr/bin/mysql -h"host_name" -u"user_name" -p"pass_word" -D"database" -f <<END-OF-DATA
select mobile from table where name="$name";
END-OF-DATA`
2.
mysql -hhostname -uuser -ppsword << EOF
mysql_cmd
EOF
如下简单例子:
#!/bin/bash
mysql -hservicedb-online -uroot -proot123 -e "use test;select * from tests;" #方法1实例
mysql -hservicedb-online -uroot -proot123 << EOF #方法2实例
use test;
select * tests;
EOF
mobile_t=`/usr/bin/mysql -h"host_name" -u"user_name" -p"pass_word" -D"database" -f <<END-OF-DATA
select mobile from table where name="$name";
END-OF-DATA`
相关文章推荐
- MySQL更新字段中部分内容&shell脚本执行命令
- shell 脚本一步一步执行命令
- 在mysql中执行shell命令
- 解决:shell脚本中,无法执行time命令,以统计某个程序执行时间
- shell脚本执行命令 . 和sh 和 source 和 ./ 的使用以及区别
- BAT脚本如何自动执行 adb shell 以后的命令
- 脚本中执行mysql命令
- crontab不能执行shell中的mysql命令
- shell脚本中导入mysql数据&&执行mysql语句
- Linux/shell命令的实际应用——while;do;循环执行脚本
- shell脚本执行mysql语句
- 【source命令在shell脚本中执行为何不生效】source not working from within shell script
- linux下shell脚本执行方法及exec和source命令
- MySQL执行外部sql脚本文件的命令
- shell脚本中导入mysql数据&&执行mysql语句
- Shell脚本中滤掉"ssh -t"执行命令时返回的/r字符
- shell脚本实现每秒执行一次任务 rsync命令使用
- shell 下执行mysql 命令
- shell 下执行mysql 命令
- shell脚本批量部署ssh认证+批量执行命令