Early in this script users and their credentials are read into variables.
The following code works as intended to check the credentials of a mysql user.
lu="test"
lp="test-password"
ldb="local_db"
if mysql -u $lu -p"$lp" $ldb -e "quit"; then
printf "true"
return 0;
else
printf "false"
return 1;
fi
As this code executes it outputs the mysql warning about using passwords on the command line. I'd like to suppress that warning from the output while still evaluating the exit code of the mysql command.
In this answer on how to suppress the error message by using mysqlcommand 2>&1 | grep -v "Warning: Using a password"
, the output is stripped of only the warning. All other output is still shown.
I've tried to integrate this into my code without success. Is there a way I can do this?