Mysqldump export Lost connection to MySQL server during query

Source: Internet
Author: User

The following statement is used to export data during mysqldump backup and export.

Mysqldump-uroot-p 'passwd'-opt-default-character-set = utf8-triggers-R-hex-blob-single-transaction-no-autocommit-master-data = 2 test_game mail> mail. SQL

An error similar to the following occurs:

Mysqldump: Error 2013: Lost connection to MySQL server during query when dumping table 'mail' at row: 1754283

Query materials

Probably because mysqldump is too late to accept the data sent from the mysql server, the Server's data will backlog in the memory waiting for sending. This wait is not indefinite, when the Server waits for more than net_write_timeout (60 seconds by default), it loses patience. The connection to mysqldump is disconnected and a Got error: 2013: Lost connection is thrown.

Adding net_write_timeout can solve the above problem. In practice, it is found that after net_write_timeout is increased, the Server consumes more memory, and sometimes even causes swap usage (it is not sure whether net_write_timeout is modified ). We recommend that you change net_write_timeout to a large value (for example, 1800) before mysqldump. After mysqldump ends, change this value to the default value of 60.

Use the following command to set the temporary global effect in the SQL command line:

Set global net_write_timeout = 1800;

After modifying this parameter, back up again and no error will be reported

Note that this parameter is not the mysqldump option, but a configuration parameter of mysql.

Other possible solutions with error: 2013:




Prohibit MySQL from performing DNS resolution on external connections. This option can eliminate the time for MySQL to perform DNS resolution.

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: 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.