"MySQL" mysqldump Backup and Recovery

Source: Internet
Author: User

Introduction:
Mysqldump is commonly used in MySQL database logical backups.

Backup operation:

    • 1. Back Up all libraries:
      mysqldump -uroot -pyourpass --all-databases > /tmp/all.dump
    • 2. Back up a single library:
      mysqldump -uroot -pyourpass test > test.dump
    • 3. Backup a single sheet:
      mysqldump -uroot -pyourpass test test_tb > test_tb.sql
    • 4. Backup stored procedures:
      mysqldump -uroot -pyourpass -n -d -t -R test > test_procedure.sql

Restore operation:
Ensure that the database to be recovered exists before recovery

    • To restore a single library:
      mysql -uroot -pyourpass test < test.dump

      or enter the database to execute the source test.dump;

    • To restore a single table from a backup of the whole library:
      cat test.dump | sed -e‘/./{H;$!d;}‘ -e ‘x;/CREATE TABLE `test_tb`/!d;q‘ > /tmp/test_tb.sql  --筛选出建表语句cat test.dump | grep --ignore-case  ‘insert into `test_tb`‘ > /tmp/insert_test_tb.sql  --筛选插入数据的insert语句

      You can then restore a single table by executing the appropriate SQL in the database as needed.

"MySQL" mysqldump Backup and Recovery

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.