Execute SQL script to create tables and rows

后端 未结 2 789
-上瘾入骨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 10:52

    If you have password for your dB then

    mysql -u <username> -p <DBName> < yourfile.sql
    
    0 讨论(0)
  • 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
    0 讨论(0)
提交回复
热议问题