Using tables with dashes in MySQL queries

Problem

You have some databases in MySQL that contain dashes in their names, and when you try to use them (ie grant access to them), you get the following error:

ERROR 1064 (42000): 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 '-db.* to 'username'@'%'' at line 1

Solution

To be able to use them, enclose the database name in backticks (`) like:

GRANT ALL on `databasename-db`.* to 'username'@'%'

Search for content in files in linux (recursively and case-independent)

Problem

You would like to find the files that contain some specific text, and would like to do it recursively (ie in a project folder), using something simpler than the find command.

Solution

You can use the following in your current top folder to search recursively, case-independent and by displaying the file number that the searched text appears, with the following:

grep -rin "TextToBeSearched" .

Getting the slug name for Digital Ocean’s images with doctl

Problem

You would like to get a list of the available images in Digital Ocean, in order to be able to use them in creating your Terraform IAC script.

Solution

By installing the command line tool doctl, (instructions here), according to the documentation (after authenticating) you can run:

doctl compute image list

But the available images are not listed. In order to be list all the images you have to add the –public option (as described here) :

doctl compute image list --public