Hi,
I'm familiar with PHP, but bash is pretty new to me.
I'm writing a bash script that logs into mysql. I need the script to test whether it's using the proper mysql user/pass, so that it can switch to another if necessary. The problem is everything I've tried throws an error, and ends the script.
What I've been doing so far looks like this (though I've tried many variations):
Code:
mysql -h localhost -u Username -pPassword <<EOF; exit; EOF
if [ "$?" != "0" ]; then
# Code that tests alternate credentials
fi
I've tried using -f to keep the errors from stopping the script, but I think that "force" does not apply to the mysql command itself. I think "force" only applies to the commands executed in mysql.
I don't see any other options in the man page that seem to apply to what I'm doing. Could have misunderstood something though.
Does anyone have some code that would work in this situation?
Thanks in advance!