开发者

Execute SQL script to create tables and rows

开发者 https://www.devze.com 2023-01-21 05:57 出处:网络
I have a datab开发者_高级运维ase 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 have a datab开发者_高级运维ase 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 know what was the command line to execute that .sql on the database I created?


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


If you have password for your dB then

mysql -u <username> -p <DBName> < yourfile.sql
0

精彩评论

暂无评论...
验证码 换一张
取 消