mysql -hhostname -uusername -ppassword db_name -e 'query to execute;'
- hostname – the host on which MySQL is installed
- username – the MySQL user that has the necessary privileges over the database
- passsword – the MySQL user password
- db_name – the name of the MySQL database that you want to query
- -e – MySQL option which will execute the statement and quit
- query to execute; – the MySQL query you want to execute enclosed in single quotes