Python-day47--mysql Data Backup and recovery

Source: Internet
Author: User

I. Introduction of IDE Tools

Master: # 1. Test + link Database #2. New library #3. New table, new field + type + constraint #4. Design table: Foreign key #  5. New Query #6. Backup Library/Table # Note: Batch add Comment: Ctrl +? Key batch to comment: Ctrl+shift+? Key

Second, MySQL data backup

# 1. Physical backup: Direct copy of database files for large database environments. But cannot be restored to heterogeneous systems such as Windows (requires platform consistency).  #2. Logical Backup: Backup is the SQL statement executed by the operation of the table, build, insert, etc., for small and medium sized databases, the efficiency is relatively low.  #3. Export table: Import the table into a text file. 

1. Using Mysqldump for logical backups

# Syntax: # mysqldump-h Server-u user name-p password database name > backup file. sql ## Single Library backup mysqldump-uroot-p123 db1 >-uroot-p123 db1 table1 table2 > d:\\db1-table1-table2.sql< c8/> #备份表 # multi-Library backup mysqldump-uroot-p123--databases db1 db2 mysql db3 >d:\\ db1_db2_mysql_ Db3.sql# back up all libraries mysqldump-uroot-p123--all-databases > D:\\all.sql

2. Restoring a logical backup

# method One:mysql-uroot-p123 day47< d:\\day47.sql      (to have day47 Library in advance)# method Two:create Database Day47;use Day47;source d:\\day47

3. View data in a database without entering the database

4. Database migration (Extended understanding)

be sure to migrate between the same versions # mysqldump-h source ip-uroot-p123--databases db1 | mysql-h target ip-uroot-p456

5. Export and import of tables

SELECT ... into OUTFILE export text file example: MySQL> SELECT *From School.student1into OUTFILE'Student1.txt'Fields TERMINATED by','//defining field separators optionally enclosed by'"'//defines what symbols to use in a string lines TERMINATED by'\ n'; //example of defining a line break MySQL command to export a text file:#mysql-u root-p123-e ' select * from Student1.school ' >/tmp/student1.txt#mysql-u root-p123--xml-e ' select * from Student1.school ' >/tmp/student1.xml#mysql-u root-p123--html-e ' select * from Student1.school ' >/tmp/student1.htmlLOAD DATA INFILE importing text files MySQL>DELETE from Student1;mysql> LOAD DATA INFILE'/tmp/student1.txt'Into TABLE school.student1fields TERMINATED by','optionally enclosed by'"'LINES TERMINATED by'\ n';

Python-day47--mysql Data 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.