简体   繁体   English

将.sql文件导入MySql数据库

[英]Import a .sql file to a MySql database

I want to import a SQL file through the command line interface. 我想通过命令行界面导入SQL文件。

I have tried the following code: 我尝试了以下代码:

mysql -u username -p database_name < file.sql

This gives me a syntax error . 这给了我一个syntax error Any help is appreciated. 任何帮助表示赞赏。

The syntax is: 语法为:

mysql -u <username> -p <database> < textfile.sql

If you do it like this the file needs to be in the same directory you are currently in. If you know where the file is you can do: 如果这样做,则文件需要与当前目录相同。如果知道文件的位置,则可以执行以下操作:

mysql -u <username> -p <database> < /path/to/file/textfile.sql

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM