MySQL mysqldump 只导出一张表

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18741287/
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:48:12  来源:igfitidea点击:

mysqldump exports only one table

mysqlinnodbmysqldump

提问by danieln

I was using mysqldump to export the database, like this:

我正在使用 mysqldump 导出数据库,如下所示:

mysqldump -u root -ppassword my_database > c:\temp\my_database.sql

Somehow, it only exports one table. Is there something I'm doing wrong?

不知何故,它只导出一张表。有什么我做错了吗?

回答by developerCK

try this. There are in general three ways to use mysqldump—

尝试这个。mysqldump的使用一般有以下三种方式——

in order to dump a set of one or more tables,

为了转储一组一个或多个表,

shell> mysqldump [options] db_name [tbl_name ...]

a set of one or more complete databases

一组一个或多个完整的数据库

shell> mysqldump [options] --databases db_name ...

or an entire MySQL server—as shown here:

或整个 MySQL 服务器——如下所示:

shell> mysqldump [options] --all-databases

回答by HMagdy

If you are dumping tables t1, t2, and t3 from mydb

如果要从 mydb 转储表 t1、t2 和 t3

mysqldump -u... -p... mydb t1 t2 t3 > mydb_tables.sql

If you have a ton of tables in mydb and you want to dump everything except t1, t2, and t3, do this You can use the --ignore-tableoption. So you could do:

如果您在 mydb 中有大量表,并且想要转储除 t1、t2 和 t3 之外的所有内容,请执行此操作您可以使用--ignore-table选项。所以你可以这样做:

mysqldump -u username -p database --ignore-table=database.table1 --ignore-table=database.table2 > database.sql

回答by Piero Alberto

Quoting this link: http://steveswanson.wordpress.com/2009/04/21/exporting-and-importing-an-individual-mysql-table/

引用此链接:http: //steveswanson.wordpress.com/2009/04/21/exporting-and-importing-an-individual-mysql-table/

  • Exporting the Table
  • 导出表

To export the table run the following command from the command line:

要导出表,请从命令行运行以下命令:

mysqldump -p --user=username dbname tableName > tableName.sql

This will export the tableName to the file tableName.sql.

这会将 tableName 导出到文件 tableName.sql。

  • Importing the Table
  • 导入表

To import the table run the following command from the command line:

要导入表,请从命令行运行以下命令:

mysql -u username -p -D dbname < tableName.sql

The path to the tableName.sql needs to be prepended with the absolute path to that file. At this point the table will be imported into the DB.

tableName.sql 的路径需要加上该文件的绝对路径。此时表将被导入到数据库中。

回答by Nids Barthwal

mysqldump -u root -p dbname table1 table2 table3 > table.sql