Before creating a new mysql user and DB, I did:
read sps -s
# Inputing and saving the sps (password) value.
echo ${sps}
# sps password value echoed.
mysql -u root -p[PASSWORD]
mysql>
CREATE user "test"@"localhost" IDENTIFIED BY "${sps}";
The problem
When I came to login with mysql -u test -p[SPS_PASSWORD_VALUE]
I got an error that access has been denied.
The password wasn't the value I gave for ${sps}
but rather ${sps}
itself, as a string.
The catch
To prove "formally" that the problem is due to the ${sps} variable not being expanded **inside** mysql shell, and therefore acts as a regular string, I created another user
test1` providing a password manually (not from a variable) and this time I could login just fine.
The question
Why when I'm inside the mysql shell, there's no variable expansion and how could I prevent that behavior or at least getting a behavior close to that?
Maybe it's a bug?