Shell脚本中执行sql语句操作mysql的5种方法
程序员文章站
2022-07-14 11:02:31
...
源:http://www.jb51.net/article/56944.htm
评:
shell脚本中MySQL提示符下调用SQL
[root@SZDB ~]# more shell_call_sql2.sh
#!/bin/bash
mysql -uroot -p123456 <<EOF
source /root/temp.sql;
select current_date();
delete from tempdb.tb_tmp where id=3;
select * from tempdb.tb_tmp where id=2;
EOF
exit;
模版:
#!/bin/bash
mysql -uroot -p123456 <<EOF
。。。。。
EOF
exit;
评:
shell脚本中MySQL提示符下调用SQL
[root@SZDB ~]# more shell_call_sql2.sh
#!/bin/bash
mysql -uroot -p123456 <<EOF
source /root/temp.sql;
select current_date();
delete from tempdb.tb_tmp where id=3;
select * from tempdb.tb_tmp where id=2;
EOF
exit;
模版:
#!/bin/bash
mysql -uroot -p123456 <<EOF
。。。。。
EOF
exit;