Reputation: 3228
I'm trying to run an update query on a db server via bash command. I have to update an IP field (which is sorted as a string) but i'm getting a syntax error...
ssh [email protected] "/usr/local/mysql/bin/mysql -D SMARTPARK -u parkuser -ppass -e 'update client SET online=0 where client_ip='192.168.42.11''"
I'm getting as error
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 '.42.11' at line 1
which is the error?
Upvotes: 1
Views: 590
Reputation: 4642
Try to escape "
character with \"
to make sure you don't escape from the string you're sending to your DB.
In other words, try to put the following in the bash file you're executing:
ssh [email protected] "/usr/local/mysql/bin/mysql -D SMARTPARK -u parkuser -ppass -e \"update client SET online=0 where client_ip='192.168.42.11'\""
Upvotes: 1