How to execute a .sql script from bash How to execute a .sql script from bash database database

How to execute a .sql script from bash


You simply need to start mysql and feed it with the content of db.sql:

mysql -u user -p < db.sql


If you want to run a script to a database:

mysql -u user -p data_base_name_here < db.sql