danieln
danieln

Reputation: 4973

mysqldump exports only one table

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?

Upvotes: 104

Views: 266277

Answers (5)

user16660074
user16660074

Reputation: 11

I did this and it worked well. All tables from the database was backed up in the .sql file successfully.

mysqldump.exe -e --databases -u<db name> -p<Password> -h<host name> <database name> --skip-lock-tables --column-statistics=0 > C:\test.sql

Upvotes: 0

Nids Barthwal
Nids Barthwal

Reputation: 2419

Here I am going to export 3 tables from database named myDB in an sql file named table.sql

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

Upvotes: 28

Rich
Rich

Reputation: 4248

In case you encounter an error like this

mysqldump: 1044 Access denied when using LOCK TABLES

A quick workaround is to pass the –-single-transaction option to mysqldump.

So your command will be like this.

mysqldump --single-transaction -u user -p DBNAME > backup.sql

Upvotes: 2

Piero Alberto
Piero Alberto

Reputation: 3943

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.

Upvotes: 56

developerCK
developerCK

Reputation: 4506

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

Upvotes: 129

Related Questions