MySQL 如何通过命令行在 Windows 上使用 mysqldump 导入 SQL 文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4755552/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 18:24:19  来源:igfitidea点击:

How to import an SQL file by using mysqldump on Windows through command line

mysql

提问by DEVOPS

How do I import an SQL file to MySQL dump using command line. I am using windows.

如何使用命令行将 SQL 文件导入 MySQL 转储。我正在使用窗户。

回答by ayush

Navigate to the directory where you have mysql and issue this command, changing the bold values to your file/database locations.

导航到您拥有 mysql 的目录并发出此命令,将粗体值更改为您的文件/数据库位置。

c:\mysql\bin\> mysql -u USERNAME -p PASSWORD database_name < filename.sql

回答by Baskaran

Simple steps to import sql file.

导入sql文件的简单步骤。

Click on WampServer and then go to MySQL=> MySQL console enter password \If no password click simply enter create database database_name; \If database already there skip this step use database_name; source D:\backup.sql \Path of database file

单击 WampServer,然后转到 MySQL=> MySQL 控制台输入密码 \如果没有密码单击只需输入 create database database_name; \如果数据库已经存在跳过这一步使用database_name; source D:\backup.sql \数据库文件路径

回答by jas jashim

Try this

尝试这个

C:\Program Files\Mysql\Mysql server 5.6\bin\mysql -u {username} -p {password} {your database name} < file-name.sql

Note here file-name.sql is in mysql server 5.6\bin

注意这里 file-name.sql 在 mysql server 5.6\bin

回答by Noor Khan

To dump all databases, use the -all-databasesoption. With that option, no database needs to be specified.

要转储所有数据库,请使用该-all-databases选项。使用该选项,无需指定数据库。

mysqldump -u username -ppassword –all-databases > dump.sql

回答by Xman Classical

Try like this:

像这样尝试:

I think you need to use the full path at the command line, something like this, perhaps:

我认为您需要在命令行中使用完整路径,例如:

C:\xampp\mysql\bin\mysql -u {username} -p {databasename} < file_name.sql

Refer this link also:

另请参阅此链接:

http://www.ryantetek.com/2011/09/importing-large-sql-files-through-command-line-when-using-phpmyadminxampp/

http://www.ryantetek.com/2011/09/importing-large-sql-files-through-command-line-when-using-phpmyadminxampp/