Logical database backup

First, the logical backup

Backup is built table, database, and other operations performed by SQL insert statements for small and medium sized databases, relatively low efficiency.

** nature: ** SQL statement is exported file

** Pros: ** no matter what storage engine, can use mysqldump backup to SQL statements

** Cons: ** slow, incompatible format emergencies may occur when importing, you can not do incremental backups and cumulative incremental backups.

Offers three levels of backup, table-level, database level, and the whole class library

Logical backup: backup is built table, database, and other operations performed by inserting SQL statements (DDL DML DCL), suitable for small databases, the efficiency is relatively low.

Data is consistent, available services: how to ensure consistent data, it automatically locks in the lock table when backup. After locking the backup.

本身为客户端工具:
远程备份语法: # mysqldump -h 服务器  -u用户名  -p密码   数据库名  > 备份文件.sql
本地备份语法: # mysqldump -u用户名  -p密码   数据库名  > 备份文件.sql
1. Common Backup Options

-A, --all-databases
backup all libraries

Example:mysqldump -uroot -p'QianFeng@123' -A > /opt/a.sql

Analysis: -A is need to specify what, direct backup entire library

-B , -databases the Test BBS MySQL
backup multiple databases

Example:mysqldump -uroot -p'QianFeng@123' -B db1 db2 db3 > /opt/a.sql

Analysis: -B may be behind with multiple databases, separated by spaces

Export specified table

Example:mysqldump -uroot -p'QianFeng@123' db1 table1 table2 > /opt/a.sql

Analysis: If you do not add -B, after the default is 库名 表名 表名behind the table must be inside in front of the library, the library name is unique, but not the table name.

-No-data, -d
does not export any data, only export the database table structure.

Example:mysqldump -uroot -p'QianFeng@123' db1 -d > /opt/a.sql

Parsing: -d good front need to specify what we want to back up data, -d refers only export the table structure.

Published 16 original articles · won praise 0 · Views 533

Guess you like

Origin blog.csdn.net/QAQkira/article/details/104932505