Execute SQL script to create tables and rows

后端 未结 2 790
-上瘾入骨i
-上瘾入骨i 2021-01-30 10:19

I have a database that I created using the CREATE DATABASE statement in the terminal and I have a .sql file full of statements creating tables and rows.

I just wanted to

2条回答
  •  粉色の甜心
    2021-01-30 11:10

    In the MySQL interactive client you can type:

    source yourfile.sql
    

    Alternatively you can pipe the data into mysql from the command line:

    mysql < yourfile.sql
    

    If the file doesn't specify a database then you will also need to add that:

    mysql db_name < yourfile.sql
    

    See the documentation for more details:

    • Executing SQL Statements from a Text File

提交回复
热议问题