views:

69

answers:

3

I want not only the "Create table" statements, but also the Inserts. What flags should i pass to mysqldump?

In addition - the database is relatively large (2-2.5G). Obviously, i want the backup to be as fast as possible. Any flags that might help?

Thanks

+1  A: 

By default the inserts are dumped.

If you want all tables to be dumped, just precise database, else give table names.

mysqldump [options] [db_name [tbl_name ...]]

To earn space you can use the flag

--compact

And to process this quicker you can use

--quick

I presume that all this information is available doing man mysqldump.

Guillaume Lebourgeois
Do note that `--compact` is only shorthand for `--skip-add-drop-table, --skip-add-locks, --skip-comments, --skip-disable-keys, and --skip-set-charset` which will save only a constant number of lines per table *and* will change the way the dump is reloaded.
Unreason
+1  A: 

The mysqldump command dumps data by default. Just issuing mysqldump dbname > dump will produce a dump with the schema and data.

To speed up the dump, use --opt parameter which turns on some options like table locking, quick, extended inserts and charset. Using --quick (which is set by --opt too) is a good way to speed up the dump if your database does not fit into memory. Use --quick alone if you can't afford to lock tables during the dump.

If your disks are slow, compress the data before writing it to disk:

mysqldump --opt dbname | gzip - > dump
jmz
what do you mean by "Use it alone"? use what alone, the --quick flag?I actually can't afford lock tables
Erik Sapir
Yes, I meant the --quick flag: mysqldump --quick dbname | gzip - > dump
jmz
A: 

You should definitively read the manual pages for mysqldump, there are many options that you should take care of (what to do with binary logs, locking of tables, format of binary fields, etc)

After that run mysqldump --help - it will tell you which options are on or off by default.

Finally, if setting various options does not bring you the required performance some people recommend setting up replication and backing up the slave, but this falls under category of hardware speed-up (as does getting faster faster storage, etc...)

Unreason