就是个EOF问题
#!/bin/sh
user="dbuser"
pass="dbpassword"
db="dbnme"
mysql -u "$user" -p"$pass" "$db" <<EOF
select * from userinfo1;
EOF
#!/bin/sh
user="dbuser"
pass="dbpassword"
db="dbnme"
sql="select * from userinfo1"
mysql -u "$user" -p"$pass" <<EOF
use $db;
$sql;
EOF