Alex Rivera | Logout

How to execute a .sql script from bash

Asked 2011-09-30T22:00:30.997
71

Basically, I need to setup a database from a bash script. I have a script db.sql that does all this. Now how do I run this script from bash?

Database system is mysql

Edit
Report

1 Answer

75

If you want to run a script to a database:

mysql -u user -p data_base_name_here < db.sql
answered 2012-03-24T04:46:26.247

Your Answer