Ramratan Gupta
Ramratan Gupta

Reputation: 1086

How to resolve backticks error while using -e with mysql client?

Hi I am trying run belo sql on Ubuntu terminal using MySQL client

mysql -u root \
 -proot -e "SELECT *  FROM knexus.redis_cache WHERE `key` LIKE '%hub.local%'"

I am getting below error

The program 'key' is currently not installed. You can install it by typing:

sudo apt-get install donkey

ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIKE '%hub.local%'' at line 1

However SQL run properly on MYSQL terminal.

I guess this might be issue character escaping issue, as I see sudo apt-get install donkey.

Upvotes: 2

Views: 138

Answers (1)

Ingo Meldau
Ingo Meldau

Reputation: 494

The ticks framing key cause the bash to treat key as a command and replace it by its output in the command. You could either try without them or put the whole command in single quotes and the %hub.local% in double quotes.

Upvotes: 2

Related Questions