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:
- Reset MySQL Root Password Very often, once we didn’t log on to MySQL database...
- Create Root Privilege User on MySQL By default, MySQL root privileges user is “root”, I always...
- PostgreSQL Database psql Command Line Query Sometime psql command line query can be useful when it...
- How to Remove MySQL Binary Log By default, MySQL 5.0 and above enables MySQL Binary Log....
- MySQL Quick Installation on FreeBSD Quick installation of MySQL Database on FreeBSD Server. Make sure...
- run sql/queries (postgres) within bash e.g. for things-to-buy in $(psql -d database-name -U username -c...
- Quick Screen Lock on Apple Mac OSX Locking your screen is critical when you are using your...
- Arrays in Bash Arrays is useful when it comes to data processing. Using...
- How to Create User with useradd in FreeBSD You can invoke “adduser” command in FreeBSD in order to...
- screen in FreeBSD default to csh as suppose to bash (preferred) After changing bash shell to a new user using chsh,...