MySQL Study ( 5、 … and )—MySQL Backup / Three paradigms of database
01 MySQL Backup
- The necessity of database backup :1. Ensure that important data is not lost 2. Data transfer
- MySQL Database backup method :1.mysqldump Backup tools 2. Database management tools , Such as SQLyog 3. Directly copy database files and related configuration files
- mysqldump Client side usage :
# Export a table
mysqldump -u user name -p password Library name Table name > file name (D:/a.sql)
# Export multiple tables
mysqldump -u user name -p password Library name surface 1 surface 2 surface 3 > file name (D:/a.sql)
# Export all tables
mysqldump -u user name -p password Library name > file name (D:/a.sql)
# Export a library
mysqldump -u user name -p password -B Library name > file name (D:/a.sql)
# Import
1. In the login mysql Under the circumstances :
source Backup file
2. Without logging in
mysql -u user name -p password Library name < Backup file
- Use SQLyog Database backup
-
Export backup data :
Select the library to export —> Right click to select backup / export —> Choose the path to save the file —> Choose the top three options as needed : Table structure only / Table data only / Table structure and table data ( If the database table data is large, it can be exported separately for backup , It is divided into export table structure and table data 2 individual sql file , Because it takes a long time to select table structure and table data at one time , When re importing, there may be problems that cannot be imported )
-
Import backup data :
Click database —> Import —> perform SQL Script —> Select the data to import —> perform
( Be careful : If the table structure and table data are saved separately during export , When importing, you need to import the table structure first , Then import the table data )
-
02 Three paradigms of database
Database design must be standardized , Non conforming data sheets may cause duplication of information , Update exception , Insertion exception , Delete exceptions and other problems
Three paradigms of database design :
- Make sure that each column is atomic , If each column is the smallest unit of data that cannot be subdivided , The first paradigm .
- Each table describes only one thing
- If a relationship satisfies the second paradigm , And no other columns except the primary key are passed that depend on the primary key , The third paradigm is satisfied .