shell脚本中执行sql脚本(mysql为例)

1、sql脚本(t.sql

insert into test.t value ("LH",88);

2、shell脚本(a.sh     为方便说明,a.sh与t.sql在同一目录下)

说明:3种执行方式,后两行也可以(已注释,感兴趣可以尝试下)

#!/bin/sh
  mysql -u root < t.sql
# mysql -u root -e "source t.sql"
# mysql -u root -e "\. t.sql"

3、执行&&执行结果

猜你喜欢

转载自www.cnblogs.com/lvlin241/p/9280103.html