Several Ways to Run MySQL Queries from Bash

In some of these examples, particularly the remote server I’ve included usernames and passwords, but you might not need it locally, depending on your mysql permissions setup.

Run and save results of sql statement against a remote mysql server

 

Run file of sql commands against a remote mysql server

 

Run file of sql commands against a local mysql server