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
To run SQL files from the terminal, you can use the source or the backslash and dot command ( \. ) Next, enter the password for your root user. The path /Users/nsebhastian/Desktop/test/main. sql above needs to be changed to the SQL file path on your computer.
You simply need to start mysql
and feed it with the content of db.sql
:
mysql -u user -p < db.sql
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With