klenwell information services : MysqlBashCommandLine

MySQL from Bash Command Line

return to DevMysql

Pattern

mysql -u[user] -p[pass] -e "COMMAND HERE"

Examples

Single Commmand

mysql -uroot -p -e "SHOW DATABASES"


Multiple Commands

mysql -uroot -p -e <<QUERY_INPUT
USE DATABASE my_database;
INSERT INTO my_table (col1, col2) VALUES ('foo', 'bar');
QUERY_INPUT


References

MySQL Commands from Bash Command Line (mindspill.net)