How can I execute an SQL command through a shell script so that I can make it automated?
I want to restore data I have collected in a SQL file using a shell script.
All of the previous answers are great. If it is a simple, one line sql command you wish to run, you could also use the -e option.
mysql -h -u -p database -e \ "SELECT * FROM blah WHERE foo='bar';"