I have observed a variety of error messages returned from mysql when called from a BASH script.
Following in one such example:
#!/bin/bash
declare -g SQL_cmd="SHOW DATABASES"
declare -g MySQL_cmd="mysql -u temp -pAbcde_0123 --skip-column-names --execute='${SQL_cmd}'"
declare -g results=$($MySQL_cmd)
printf "command: $MySQL_cmd\n"
printf "results: $results\n"
When I run this script, the output is as follows:
ERROR 1044 (42000): Access denied for user 'temp'@'localhost' to database 'DATABASES''
command: mysql -u temp -pAbcde_0123 --skip-column-names --execute='SHOW DATABASES'
results:
However, if I copy and paste the command from the output above, it returns the following:
17:26 >mysql -u temp -pAbcde_0123 --skip-column-names --execute='SHOW DATABASES'
+--------------------+
| information_schema |
| temporary |
+--------------------+
Which is exactly what I would expect.
Can someone explain what is going on here?
Thank you.