bash – dealing with backtics ” ` ” in mysql statement

problem :

using backticks in bash for mysql statements. e.g. :

mysql -u username -h host -e “GRANT SELECT, LOCK TABLES ON `somedatabase`.* TO ‘someuser’@’somehost’;” -p<password with no space after parameter>

would get an error :

./scriptname: line 5: somedatabase: command not found

solution :

escape () the backticks ” ` ” surround “somedatabase”

mysql -u username -h host -e “GRANT SELECT, LOCK TABLES ON `somedatabase`.* TO ‘someuser’@’somehost’;” -p<password with no space after parameter>