mysqldump exports only one table

2020-05-12 13:53发布

问题:

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

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

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

回答1:

try this. There are in general three ways to use 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:

shell> mysqldump [options] --all-databases


回答2:

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

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-table option. So you could do:

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


回答3:

Quoting this link: 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.

  • 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.



回答4:

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