Export mysql database structure AND data via SSH

HI ALL,

I decided to export (backup) my database structure AND data through the SSH. I managed to export the mysql database structure with :


mysqldump -u USER -p DB_NAME > FILE_NAME.sql

BUT I need to export the DATA within the tables and I couldn’t find the command line for that… Can someone give a link or the command itself to do that? Thank you advanced!!!

Thank you All for your helpful posts guys!!! I appreciate your expertise!

Does that mean you’ve solved the problem?

I got no error message during the dump, but I don’t know how can I check the database size in terminal… I only know that 2 tables have over 5000 rows.

Did you notice any error during mysqldump ? What is the database size in total?

Well, yes, the command line I posted first WILL export some data in my case but not EVERYTHING. I have a table in the database with thousands of email addresses, but when I check FILENAME.sql it only contains a few hundreds - I dunno why…

The command that you have mentioned will export ALL the data (tables structure and data) inside that database. If you want to export any specific table structure and data you can use:

mysqldump -u USER -p DB_NAME TABLE_NAME > FILE_NAME.sql

This will export only specified table.

You could of course re-import the just dumped data and do a SELECT COUNT(*) query over that. If you also do that over the original data you know many -if any- rows are missing from the exported data.

[QUOTE=dujmovicv;4685624]


mysqldump -u USER -p DB_NAME > FILE_NAME.sql

Have you checked FILE_NAME.sql?
When I run that comment on one of my MySQL databases it exports all the data just fine …