- mysql hostをport foward
ssh -M -S ctl_path -Nf -L 33306:db-instance:3306 ec2-user@10.0.0.0 -i ~/.ssh/aws.pem
- control socketをチェック
ssh -S ctl_path -O check ec2-user@10.0.0.0
- control socketを終了
ssh -S ctl_path -O exit ec2-user@10.0.0.0
result=$(mysql -u user -h 127.0.0.1 -P 33306 -ppass dbname -N -se "SELECT id, name FROM member LIMIT 1")
IFS=$'\t' read -ra columns <<< result
echo "id: ${columns[0]}"
echo "name: ${columns[1]}"