I use shell script to communicate to a MySQL database. MySQL supports specifying query as a shell argument, like this:
mysql my_db -B -N -e "select id from Table"
However, if I have a parameter, which I'd like to use in a query, how can I get protection against injection attacks?
A naive way is to just paste variable value to the request, but it's not very secure:
mysql my_db -B -N -e "select id from Table where name='$PARAM'"
Are there any tricks or documented interfaces to make an injection-safe queries from command line?