Source: http://www.jb51.net/article/56944.htm
Comments:
Calling SQL at the MySQL prompt in a shell script
[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;
Template:
#!/bin/bash
mysql - uroot -p123456 <<EOF
. . . . .
EOF
exit;
5 ways to execute sql statement in shell script to operate mysql
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=326085662&siteId=291194637
Recommended
Ranking