Mysql's dump database command recently used the mysql dump database table to record the usage of this command: www.2cto.com mysqldump backup: mysqldump-u username-p password-h host database a-w "SQL condition" -- lock-all-tables> path case: mysqldump-uroot-p1234-hlocalhost db1 a-w "id in (select id from B)" -- lock-all-tables> c: \ aa.txt mysqldump restore: mysqldump-u user name-p password-h host database <path case: mysql-uroot-p1234 db1 <c: \ aa.txt mysqldump export by condition: mysqldump-u username-p password-h host database a -- where "Condition Statement" -- no-Table creation> path my Sqldump-uroot-p1234 dbname a -- where "tag = '88 '" -- no-create-info> c: \. sqlmysqldump: mysqldump-u username-p password-h host database <path case: mysql-uroot-p1234 db1 <c: \ a.txt mysqldump export table: mysqldump-u username-p password-h host database table case: mysqldump-uroot-p sqlhk9 a -- no-data tell me some of the main parameters of mysqldump -- compatible = name it tells mysqldump, the exported data will be compatible with the database or the old MySQL server. The values can be ansi, mysql323, mysql40, postgresql, oracle, mssql, db2, maxdb, no_key_options, no_tables_options, and no_field_options. Separate them with commas. Of course, it does not guarantee full compatibility, but is as compatible as possible. -- Complete-insert: The data exported by-c adopts the complete INSERT method containing the field name, that is, all values are written in one row. This can improve the insertion efficiency, but may be affected by the max_allowed_packet parameter, resulting in insertion failure. Therefore, you need to use this parameter with caution. At least I do not recommend this parameter. -- Default-character-set = charset specifies the character set used to export data. If the data table does not use the default latin1 character set, this option must be specified during export, otherwise, garbled characters will occur after the data is imported again. -- Disable-keys: tells mysqldump to add/* at the beginning and end of the INSERT statement /*! 40000 alter table table disable keys */; And /*! 40000 alter table table enable keys */; Statement, which greatly improves the speed of the insert statement because it re-creates the index after all data is inserted. This option is only applicable to MyISAM tables. -- Extended-insert = true | false by default, mysqldump enables the -- complete-insert mode. If you do not want to use it, set this option to false. -- Hex-blob exports binary string fields in hexadecimal format. This option is required if binary data exists. The affected field types include BINARY, VARBINARY, and BLOB. -- Lock-all-tables,-x submits a request before starting export to lock all tables in all databases to ensure data consistency. This is a global read lock and the -- single-transaction and -- lock-tables options are automatically disabled. -- Lock-tables: it is similar to -- lock-all-tables, but instead of locking all tables in the database. This option is only applicable to MyISAM tables. For Innodb tables, you can use the -- single-transaction option. -- No-create-info,-t only exports data, without adding the create table statement. -- No-data,-d: only the database table structure is exported without exporting any data. -- Opt is just a quick option, it is equivalent to adding the -- add-drop-tables -- add-locking -- create-option -- disable-keys -- extended-insert -- lock-tables -- quick -- set-charset option at the same time. This option allows mysqldump to export data quickly and export data back quickly. This option is enabled by default, but can be disabled with -- skip-opt. Note: If the -- quick or -- opt option is not specified when running mysqldump, the entire result set is stored in the memory. If you export a large database, problems may occur. -- Quick,-q this option is useful when exporting large tables. It forces mysqldump to directly output records from server queries rather than cache all records into memory. -- Routines,-R: Export stored procedures and user-defined functions. -- Single-transaction: This option submits a begin SQL statement before exporting data. BEGIN does not block any applications and ensures Database Consistency during export. It is only applicable to transaction tables, such as InnoDB and BDB. This option and the -- lock-tables option are mutually exclusive, Because lock tables will implicitly commit any pending transactions. To export a large table, use the -- quick option. -- Triggers: export the trigger at the same time. This option is enabled by default. Use -- skip-triggers to disable it. For details about other parameters, see the manual. I usually use the following SQL to back up the MyISAM table: /usr/local/mysql/bin/mysqldump-uyejr-pyejr "-- default-character-set = utf8 -- opt -- extended-insert = false" -- triggers-R -- hex-blob -x db_name> db_name. SQL: /usr/local/mysql/bin/mysqldump-uyejr-pyejr "-- default-character-set = utf8 -- opt -- extended-insert = false" -- triggers-R -- hex-blob -- single-transaction db_name> db_name. SQL. In addition, if you want to implement online backup, You can also use the -- master-data parameter as follows: /usr/local/mysql/bin/mysqldump-uyejr-pyejr "-- default-character-set = utf8 -- opt -- master-data = 1" -- single-transaction -- flush-logs db_name> db_name. SQL only requests the lock table at the beginning, then refresh the binlog, and add the change master statement to the exported file to specify the binlog location of the current backup. If you want to restore the file to slave, you can use this method. 1.2 restoring the file backed up with mysqldump is an SQL script that can be directly imported. There are two ways to import data. Directly use the mysql client, for example,/usr/local/mysql/bin/mysql-uyejr-pyejr db_name <db_name. SQL, and use the SOURCE syntax (the experiment is not successful !!!) In fact, this is not a standard SQL syntax, but a function provided by the mysql client, such as: SOURCE/tmp/db_name. SQL; here you need to specify the absolute path of the file, it must be a file that the mysqld running user (such as nobody) has the permission to read. Other: export the database energy_pf: C :\> mysqldump-uroot-psunray200 energy_pf> energy_pf.20121226. SQL to export a table: C: \> mysqldump-h192.168.2.200-plugin-penergy_pf-t energy_pf -- table DAT_PRODUCE> plugin import: C: \> mysql-h192.168.2.200-uenergy_pf-penergy_pf energy_pf <usage of the dispatch command line: mysqldump-u use the primary name-p password-d Data Warehouse name table name Script Name; 1. Export the table structure of the data warehouse as dbname (the primary name is root, the password is dbpasswd and the generated Script Name Is db. SQL) mysqldump-uroot-pdbpasswd-d dbname> db. SQL; 2. Export a database named dbname. The mysqldump-uroot-pdbpasswd-d dbname test> db structure of a table named "test. SQL; 3. Export all table structures and table data records (without-d) in the database dbname mysqldump-uroot-pdbpasswd dbname> db. SQL; 4. Export the database dbname to a table (test) structure and table data volume (without-d) mysqldump-uroot-pdbpasswd dbname test> db. SQL;