How to execute a .sql script from bash

前端 未结 2 594
闹比i
闹比i 2021-01-30 12:42

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

相关标签:
2条回答
  • 2021-01-30 13:13

    If you want to run a script to a database:

    mysql -u user -p data_base_name_here < db.sql
    
    0 讨论(0)
  • 2021-01-30 13:29

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

    mysql -u user -p < db.sql
    
    0 讨论(0)
提交回复
热议问题