1、#!/bin/bash
#define utilities's path and parametes
MYSQL="/usr/local/mysql/bin/mysql"
TARGET_HOST="192.168.222.176"
TARGET_DATABASE="test"
TARGET_TABLE="t1"
sql="select id from $TARGET_DATABASE.$TARGET_TABLE"
$MYSQL -h $TARGET_HOST -u root -p123456 -e "${sql}"
2、
#!/bin/bash
result=`mysql -h remotehost -u root -ppassword << EOF
select id from test.t1 ;
EOF`
阅读(1285) | 评论(0) | 转发(0) |