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>

Related posts:

  1. How to Remove MySQL Binary Log By default, MySQL 5.0 and above enables MySQL Binary Log....
  2. MySQL Quick Installation on FreeBSD Quick installation of MySQL Database on FreeBSD Server. Make sure...
  3. run sql/queries (postgres) within bash e.g. for things-to-buy in $(psql -d database-name -U username -c...
  4. Quick Screen Lock on Apple Mac OSX Locking your screen is critical when you are using...
  5. Arrays in Bash Arrays is useful when it comes to data processing. Using...
  6. screen in FreeBSD default to csh as suppose to bash (preferred) After changing bash shell to a new user using chsh,...

Leave a Reply