Methods for backing up with the-W statement in Mysqldump _mysql

Source: Internet
Author: User

When we use mysqldump to back up data, we have an option of –where/W, which allows you to specify a backup condition, which is explained by:

-W,--where=name  Dump only selected records. Quotes are mandatory

We can do a test, for example:

mysqldump--single-transaction-w ' ID < 10000 ' mydb mytable > Mydump.sql

This is the time to back up all the records of id< 10000 in the MyTable table. Suppose we also want to add a time range condition, such as:

mysqldump--single-transaction-w "ID < 10000 and Logintime < Unix_timestamp (' 2014-06-01 ')" MyDB mytable > Mydum P.sql

Here, you must pay attention to single and double quotes to avoid this behavior:

mysqldump--single-transaction-w ' ID < 10000 and Logintime < Unix_timestamp (' 2014-06-01 ') ' MyDB mytable > Mydu Mp.sql

In this case, the result condition will be resolved as follows:

WHERE ID < 10000 and Logintime < Unix_timestamp (2014-06-01)

The keen-eyed students will find that the time conditions become:

WHERE ID < 10000 and Logintime < Unix_timestamp (2014-06-01)

It becomes:

Unix_timestamp (2007)--2014-6-1 = 2007

This is very different from our original idea, so be careful.

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.