ITeye博客

shell脚本中执行mysql命令

junmail · 2015-04-01 11:30 · MySQL · 数据库 · Markdown

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

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。