Home > other >  A full backup
A full backup

Time:10-09

# # # # # backup table

` ` ` shell
Grammar: # mysqldump -u root - p1 db1 t1 & gt;/db1. T1. Bak
[root @ mysql server - ~] # mkdir/home/back # create backup directory
[root @ mysql server - ~] # mysqldump - uroot -p 'qf123' company employee5 & gt;/home/back/company. Employee5. Bak
The mysqldump: [Warning] Using a password on the command line interface can be insecure.
Backup multiple tables:
Grammar: mysqldump -u root - p1 db1 t1 t2 & gt;/db1. T1_t2. Bak
[root @ mysql server - ~] # mysqldump - uroot -p 'qf123' company new_t1 new_t2 & gt;/home/back/company. New_t1_t2. Bak
` ` `

# # # # # 3, the backup library

` ` ` shell
Backup a library: all table full backup is equivalent to the repository,
Grammar: # mysqldump -u root - p1 db1 & gt;/db1. Bak
[root @ mysql server - ~] # mysqldump - uroot -p 'qf123' company & gt;/home/back/company. Bak
Backup multiple libraries (B) :
Grammar: mysqldump -u root - p1 - B db1 db2 db3 & gt;/db123 bak
[root @ mysql server - ~] # mysqldump - uroot -p 'qf123' - B company testdb & gt;/home/back/company_testdb bak
Backup all the libraries:
Grammar: # mysqldump -u root - p1 - A & gt;/alldb bak
[root @ mysql server - ~] # mysqldump - uroot -p 'qf123' -a & gt;/home/back/allbase bak
` ` `

To look at the below directory:

! [1566293795577] (./assets/1566293795577. PNG)

# # # # # 4, restore the database and table

* * in order to ensure the data consistency, should stop before restoring data database foreign services, stop the binlog log because binlog using binlog, also can produce the binlog log log restore data on * *

For experimental effect to backup of the database and table just now deleted, landing database:

/root @ mysql server - ~ # mysql - uroot - pqf123

Mysql> Show the databases;
! [1566294122629] (./assets/1566294122629. PNG)

Mysql> The drop database company;
Mysql> \ q

# # # # # 5, restore the library

` ` ` shell
Log in mysql to create a library
Mysql> The create database company;
Recovery:
[root @ mysql server - ~] # mysql - uroot -p 'qf123' company & lt;/home/back/company. Bak
` ` `

# # # # # 6, restore table

` ` ` shell
Log in to just restore the library of one of the tables delete
Mysql> Show the databases;
Mysql> Use company
Mysql> Show tables;
+ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +
| Tables_in_company |
+ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +
| employee5 |
| new_t1 |
| new_t2 |
+ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +
Mysql> Drop table employee5;
Resume:
Mysql> The set sql_log_bin=0; # stop binlog log (optional)
Query OK, 0 rows affected (0.00 SEC)
Mysql> The source/home/back/company. Employee5. Bak. -- -- -- -- -- -- -- add path and backup file
Recovery mode 2:
# mysql -u root - p1 db1 & lt; Db1. T1. Bak
The library backup file path
` ` `

# # # # # 7, backup and restore table structure

` ` ` shell
1. The backup table structure:
Grammar: mysqldump - uroot - p123456 - d databasename tablename & gt; SQL
the dump.[root @ mysql server - ~] # mysqldump - uroot -p 'qf123' - d company employee5 & gt;/home/back/emp. Bak
Restore table structure:
Log in to create a database library
Mysql> The create database t1;
Grammar: # mysql -u root - p1 - D db1 & lt; Db1. T1. Bak
[root @ mysql server - ~] # mysql - uroot -p 'qf123' -d t1 & lt;/home/back/emp. Bak
` ` `

See data:

! [1566295893236] (./assets/1566295893236. PNG)
  • Related