#!/bin/bash
read -p "Enter your account:" acct #提示用户输入用户名
read -s -p "Enter your password:" passwd #提示用户输入密码,密码不显示
echo #输出回车
echo "$acct"
echo $passwd
#读取文件内容,赋值给变量
read dbname ip_addr db_user db_passwd db_port <<< $( grep "^$1"$' ' "/home/shell/test.txt" | awk -F ' ' '{print $1,$2,$3,$4,$5}' )
#连接mysql
mysql -h"${ip_addr}" -u"${db_user}" -p"${db_passwd}" -P"${db_port}" -D"dbname"