MySQL review mysqldump command

Source: Internet
Author: User
Tags mysql backup

MySQL has many Database Import methods. However, these are only half of the data transferred from the database, and the other half are the data exported from the database. Because, in many cases, we need to export data for necessary backup. The cost of data is expensive, so you should be careful when dealing with them. Generally, phpMyAdmin Based on the B/S mode is commonly used, as well as MySQL-front, navicat MySQL and other tools, there are many tools, but it is also necessary to master the built-in MySQL backup tools. Here is how to use the mysqldump command:

(The mysqldump command is located in the MySQL/bin directory)
Mysqldump is similar to the opposite tool in many aspects. They have the same options. However, mysqldump can do more. It can load the entire database into a separate text file. This package contains all the SQL commands required to recreate your database. This command gets all the modes (schema, which is explained later) and converts them into DDL syntax (create statement, that is, database Definition Statement) to get all the data, create an insert statement from the data. This tool reverses all the designs in your database. Because everything is contained in a text file. This text file can be imported back to MySQL using a simple batch processing and a suitable SQL statement. This tool is incredibly simple and fast. There will never be a headache.

Therefore, if you load the content of the entire database eays_studio to a file, you can use the following command:
Go to DoS (if you have set the environment variable) mysql-uroot-P eays_studio> D:/backup. SQL
You may only need to specify a backup table, for example, the BBS table under eays_studio, as follows:
Mysql-uroot-P eays_studio BBS> D:/backup. sqlbackup. SQL
This is very flexible. You can even use the WHERE clause to select the records you need to export to the file. To achieve this purpose, you can use a command similar to the following:
Mysqldump-uroot-P where = "user_id> 2000" eays_studio BBS> D:/backup. SQL

the mysqldump tool has a large number of options. The following table lists some options:
Option/option action/action saved med
-- add-drop-Table
This option adds the drop table if exists statement before each table, this ensures that there will be no errors when importing data back to the MySQL database, because each time the data is imported back, the system first checks whether the data exists, if yes, the
-- add-locks
option will be deleted, and a lock table and unlock TABLE statement will be bundled in the insert statement. This prevents other users from performing table operations when these records are re-imported to the database
-C or-complete_insert
. This option causes the mysqldump command to generate an insert statement plus column (field). This option is useful when exporting data to another database.
-- delayed-insert: add the delay option to the INSERT command.
-f or-flush-logs uses this option to refresh the log of the MySQL server before executing the export.
-f or-force uses this option, even if an error occurs, continue to export
-- full option to add the additional information to the Statement of create table
-l or-lock-tables to use this option, when exporting a table, the server locks the table.
-T or-no-create-info
the mysqldump command does not create the create table statement, this option is convenient when you only need data instead of DDL statements.
-D or-no-data does not create an insert statement for the mysqldump command.
you can use this option when you only need DDL statements.
-- opt this option will enable all options that will increase the File Export speed and create a file that can be imported more quickly.
the-Q or-quick option prevents MySQL from reading the entire exported content into the memory and then exporting it. Instead, MySQL writes the exported content to the export file when reading the exported content.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.