I'm trying to do the following:
OUTPUT=$(su - mysql -c "mysql --skip-column-names --raw --host=localhost --port=3306 --user=user --password=pass -e 'show variables where variable_name = "max_connections"'")
And execute this via a shell script on the local box... however, I get this returned:
ERROR 1054 (42S22) at line 1: Unknown column 'max_connections' in 'where clause'
If I just do the command locally on the box, without bash:
sudo su - mysql -c "mysql --skip-column-names --raw --host=localhost --port=3306 --user=user --password=pass -e 'show variables where variable_name = "max_connections"'"
I get the output expected... so it's like maybe bash is parsing out my delimiters wrong? A related question revealed that I couldn't use single-quote separators for my variable_name
, which looks like what bash is attempting to parse my "
as?
Update: To demonstrate the issue with single-quotes:
mysql@gossdevmydb0119.abn-sjl.ea.com:~
-> mysql --skip-column-names --raw --host=localhost --port=3306 --user=user --password=pass -e 'show variables where variable_name = 'max_connections''
ERROR 1054 (42S22) at line 1: Unknown column 'max_connections' in 'where clause'
mysql@gossdevmydb0119.abn-sjl.ea.com:~
-> mysql --skip-column-names --raw --host=localhost --port=3306 --user=user --password=pass -e 'show variables where variable_name = "max_connections"'
+-----------------+------+
| max_connections | 2000 |
+-----------------+------+