MysqlUser='root'
MysqlPassword=''
function CheckMysqlPassword()
{
if [ -z $MysqlPassword ]
then
cmdResult=`mysql -u$MysqlUser -e quit 2>&1`
else
cmdResult=`mysql -u$MysqlUser -p$MysqlPassword -e quit 2>&1`
fi
cmdResultLineCount=`echo $cmdResult | wc -c`
if(( cmdResultLineCount > 1 ))
then
printf "Error occurred! /n" #$cmdResult!/n"
else
printf "Connect mysql successfully! /n"
fi
#printf "cmdResult = $cmdResult /n"
#! for more details:
#! ERROR 1045 (28000): Access denied for user 'root'@'localhost'
AccessDenied=`echo $cmdResult | grep Access.denied | wc -c`
#if (( AccessDenied > 1 ))
#then
# printf "Connect failed, access denied./n"
#fi;
#! Can't connect to local MySQL server through socket ...
#CannotConnect=`echo $cmdResult | grep Can.t.connect | wc -c`
#if (( CannotConnect > 1 ))
#then
# printf "Connect faild, mysql may be not started./n"
#fi
}
printf "Please input the password for mysql root user:"
read MysqlPassword
CheckMysqlPassword