偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

數(shù)據(jù)恢復(fù)新姿勢(shì):使用MySQL Shell進(jìn)行更高效靈活的數(shù)據(jù)恢復(fù)

數(shù)據(jù)庫(kù) MySQL
MySQL Shell的數(shù)據(jù)恢復(fù)操作有很多可選參數(shù)便于靈活操作,大家可以自己實(shí)操實(shí)驗(yàn)一下。也可以通過(guò)修改并發(fā)參數(shù)來(lái)對(duì)比其他邏輯備份工具的效率。

上篇文章(轉(zhuǎn)戰(zhàn)MySQL Shell!數(shù)據(jù)庫(kù)備份新姿勢(shì),輕松搞定備份操作!)簡(jiǎn)單介紹了使用MySQL Shell進(jìn)行數(shù)據(jù)庫(kù)備份,本文基于上文的備份進(jìn)行數(shù)據(jù)恢復(fù)演示操作。

一、恢復(fù)單表

因?yàn)樯洗蝹浞莸谋硎莟estdb1.test1表,如果恢復(fù)到當(dāng)前庫(kù),則可以先刪除該庫(kù)中的表,再恢復(fù)。

1、先刪除庫(kù)里的表

# mysqlsh -u root  -p -S /data/mysql/mysql3306/tmp/mysql.sock
Please provide the password for 'root@/data%2Fmysql%2Fmysql3306%2Ftmp%2Fmysql.sock': *********
Save password for 'root@/data%2Fmysql%2Fmysql3306%2Ftmp%2Fmysql.sock'? [Y]es/[N]o/Ne[v]er (default No): 
MySQL Shell 8.0.35
Copyright (c) 2016, 2023, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates.
Other names may be trademarks of their respective owners.
Type '\help' or '\?' for help; '\quit' to exit.
Creating a session to 'root@/data%2Fmysql%2Fmysql3306%2Ftmp%2Fmysql.sock'
Fetching schema names for auto-completion... Press ^C to stop.
Your MySQL connection id is 83
Server version: 8.0.33-25 Percona Server (GPL), Release 25, Revision 60c9e2c5
No default schema selected; type \use <schema> to set one.
 MySQL  localhost  JS > \sql
Switching to SQL mode... Commands end with ;
Fetching global names for auto-completion... Press ^C to stop.
 MySQL  localhost  SQL > use testdb1;
Default schema set to `testdb1`.
Fetching global names, object names from `testdb1` for auto-completion... Press ^C to stop.
 MySQL  localhost  testdb1  SQL > show tables;
+-------------------+
| Tables_in_testdb1 |
+-------------------+
| test1             |
+-------------------+
1 row in set (0.0010 sec)
 MySQL  localhost  testdb1  SQL > drop table test1;
Query OK, 0 rows affected (0.0518 sec)
 MySQL  localhost  testdb1  SQL >

2、修改參數(shù)

進(jìn)行數(shù)據(jù)恢復(fù)時(shí)local_infile參數(shù)需要修改為on,因此需先調(diào)整參數(shù),否則將會(huì)報(bào)錯(cuò),例如:

MySQL  localhost  testdb1  SQL > \js
Switching to JavaScript mode...
 MySQL  localhost  testdb1  JS > util.loadDump('/data/backup/backup_tables');
ERROR: The 'local_infile' global system variable must be set to ON in the target server, after the server is verified to be trusted.
Util.loadDump: local_infile disabled in server (MYSQLSH 53025)
 MySQL  localhost  testdb1  JS > \sql
Switching to SQL mode... Commands end with ;
 MySQL  localhost  testdb1  SQL > set global local_infile=on;
Query OK, 0 rows affected (0.0002 sec)

圖片

3、進(jìn)行單表恢復(fù)

上面已經(jīng)刪除了原庫(kù)里的表,現(xiàn)在通過(guò)備份進(jìn)行恢復(fù)。

MySQL  localhost  testdb1  SQL > \js
Switching to JavaScript mode...
 MySQL  localhost  testdb1  JS >  util.loadDump('/data/backup/backup_tables');
Loading DDL and Data from '/data/backup/backup_tables' using 4 threads.
Opening dump...
Target is MySQL 8.0.33-25. Dump was produced from MySQL 8.0.33-25
Scanning metadata - done       
Checking for pre-existing objects...
Executing common preamble SQL
Executing DDL - done       
Executing view DDL - done       
Starting data load
Executing common postamble SQL                       
100% (157 bytes / 157 bytes), 0.00 B/s, 1 / 1 tables done
Recreating indexes - done       
1 chunks (8 rows, 157 bytes) for 1 tables in 1 schemas were loaded in 0 sec (avg throughput 157.00 B/s)
0 warnings were reported during the load.                
 MySQL  localhost  testdb1  JS >

圖片

查看恢復(fù)結(jié)果:表及數(shù)據(jù)已恢復(fù)。

圖片

恢復(fù)過(guò)程中,對(duì)應(yīng)的備份路徑下會(huì)生成一個(gè)load-progress.*.json文件,該文件記錄了恢復(fù)進(jìn)度及結(jié)果,以便于斷點(diǎn)續(xù)處理,文件存儲(chǔ)的具體內(nèi)容如下:

注:如果需多次進(jìn)行相同操作時(shí),注意修改改文件內(nèi)容或刪除該文件,或者自定義一個(gè)文件,例如:

util.loadDump("PrefixPARURL", progressFile: "progress.json"})

4、恢復(fù)至其他庫(kù)

很多實(shí)際情況下的數(shù)據(jù)恢復(fù)是為了將備份中的一部分?jǐn)?shù)據(jù)恢復(fù)至目標(biāo)表,或進(jìn)行數(shù)據(jù)對(duì)比,因此不能將已存在的表刪除。那么建議創(chuàng)建一個(gè)臨時(shí)恢復(fù)用的庫(kù)或在其他實(shí)例上創(chuàng)建新庫(kù)進(jìn)行恢復(fù)。那么,恢復(fù)至其他庫(kù)(庫(kù)名不一樣),該如何操作呢?具體操作如下:

先創(chuàng)建一個(gè)空庫(kù):

MySQL  localhost  testdb1  SQL > create database rec;
Query OK, 1 row affected (0.0220 sec)
 MySQL  localhost  testdb1  SQL > use rec;
Default schema set to `rec`.
Fetching global names, object names from `rec` for auto-completion... Press ^C to stop.
 MySQL  localhost  rec  SQL > show tables;
Empty set (0.0011 sec)
 MySQL  localhost  rec  SQL >

圖片

恢復(fù)rec庫(kù)并查看結(jié)果:

MySQL  localhost  rec  JS > util.loadDump('/data/backup/backup_tables',{"schema":"rec"});
Loading DDL and Data from '/data/backup/backup_tables' using 4 threads.
Opening dump...
Target is MySQL 8.0.33-25. Dump was produced from MySQL 8.0.33-25
NOTE: Load progress file detected. Load will be resumed from where it was left, assuming no external updates were made.
You may enable the 'resetProgress' option to discard progress for this MySQL instance and force it to be completely reloaded.
Scanning metadata - done       
Executing common preamble SQL
Executing DDL - done       
Executing view DDL - done       
Starting data load
100% (157 bytes / 157 bytes), 0.00 B/s, 0 / 1 tables done
Recreating indexes - done       
Executing common postamble SQL                           
1 chunks (8 rows, 314 bytes) for 1 tables in 1 schemas were loaded in 0 sec (avg throughput 157.00 B/s)
0 warnings were reported during the load.                
 MySQL  localhost  rec  JS > \sql
Switching to SQL mode... Commands end with ;
 MySQL  localhost  rec  SQL > use rec;
Default schema set to `rec`.
Fetching global names, object names from `rec` for auto-completion... Press ^C to stop.
 MySQL  localhost  rec  SQL > show tables;
+---------------+
| Tables_in_rec |
+---------------+
| test1         |
+---------------+
1 row in set (0.0012 sec)
 MySQL  localhost  rec  SQL > select  count(*) from test1;
+----------+
| count(*) |
+----------+
|        8 |
+----------+
1 row in set (0.0033 sec)
 MySQL  localhost  rec  SQL >

圖片

數(shù)據(jù)已恢復(fù),且數(shù)據(jù)條數(shù)一致。

此時(shí)的備份文件目錄里的load-progress文件內(nèi)容會(huì)增加一批:

圖片

二、恢復(fù)單個(gè)schema

因?yàn)榛謴?fù)至和備份庫(kù)名一致的庫(kù)需刪除原庫(kù),因此就不演示該操作,而采用恢復(fù)至其他庫(kù)的方式演示。

1、創(chuàng)建一個(gè)新庫(kù)

MySQL  localhost  rec  SQL > use rec1;
Default schema set to `rec1`.
Fetching global names, object names from `rec1` for auto-completion... Press ^C to stop.
 MySQL  localhost  rec1  SQL > show tables;
Empty set (0.0011 sec)
 MySQL  localhost  rec1  SQL >

圖片

2、進(jìn)行數(shù)據(jù)恢復(fù)

從上期備份的schema中恢復(fù)至rec1庫(kù),添加schema參數(shù)即可。

具體步驟如下:

MySQL  localhost  rec1  SQL > \js
Switching to JavaScript mode...
 MySQL  localhost  rec1  JS > util.loadDump('/data/backup/backup_schemas',{"schema":"rec1"})
Loading DDL and Data from '/data/backup/backup_schemas' using 4 threads.
Opening dump...
Target is MySQL 8.0.33-25. Dump was produced from MySQL 8.0.33-25
Scanning metadata - done       
Checking for pre-existing objects...
Executing common preamble SQL
Executing DDL - done       
Executing view DDL - done       
Starting data load
1 thds loading | 100% (14.06 MB / 14.06 MB), 27.90 MB/s, 11 / 11 tables done
Executing common postamble SQL                                              
Recreating indexes - done       
12 chunks (862 rows, 14.06 MB) for 11 tables in 1 schemas were loaded in 1 sec (avg throughput 14.06 MB/s)
0 warnings were reported during the load.                                   
 MySQL  localhost  rec1  JS >

圖片

3、查看恢復(fù)結(jié)果

可見(jiàn),表已恢復(fù)至rec1庫(kù)中。

圖片

執(zhí)行恢復(fù)操作時(shí),對(duì)應(yīng)的備份目錄也生成了load-progress.*.json文件,內(nèi)容如下:

圖片

三、從整庫(kù)備份中恢復(fù)

1、恢復(fù)整個(gè)實(shí)例的庫(kù)

恢復(fù)整庫(kù)時(shí),如果目標(biāo)庫(kù)已經(jīng)存在,則需要先刪除(同恢復(fù)單表或單庫(kù)類似),之后才可以進(jìn)行恢復(fù),否則會(huì)報(bào)庫(kù)及表已經(jīng)存在的錯(cuò)誤。本文為了演示,先刪除之前的庫(kù),生產(chǎn)環(huán)境千萬(wàn)別刪庫(kù)?。?!

MySQL  localhost  rec1  JS > \sql
Switching to SQL mode... Commands end with ;
 MySQL  localhost  rec1  SQL > drop database testdb;
Query OK, 11 rows affected (0.2389 sec)
 MySQL  localhost  rec1  SQL > drop database testdb1;
Query OK, 1 row affected (0.0276 sec)
 MySQL  localhost  rec1  SQL > \js
Switching to JavaScript mode...
 MySQL  localhost  rec1  JS > util.loadDump('/data/backup');
Loading DDL and Data from '/data/backup' using 4 threads.
Opening dump...
Target is MySQL 8.0.33-25. Dump was produced from MySQL 8.0.33-25
NOTE: Load progress file detected. Load will be resumed from where it was left, assuming no external updates were made.
You may enable the 'resetProgress' option to discard progress for this MySQL instance and force it to be completely reloaded.
Scanning metadata - done       
Executing common preamble SQL
Executing DDL - done       
Executing view DDL - done       
Starting data load
1 thds loading | 100% (14.06 MB / 14.06 MB), 8.39 MB/s, 12 / 12 tables done
Executing common postamble SQL                                             
Recreating indexes - done       
13 chunks (870 rows, 14.06 MB) for 12 tables in 2 schemas were loaded in 1 sec (avg throughput 14.06 MB/s)
0 warnings were reported during the load.                                  
 MySQL  localhost  rec1  JS > \sql
Switching to SQL mode... Commands end with ;
 MySQL  localhost  rec1  SQL > show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| rec                |
| rec1               |
| sys                |
| testdb             |
| testdb1            |
+--------------------+
8 rows in set (0.0009 sec)
 MySQL  localhost  rec1  SQL >

圖片

可見(jiàn),以上被刪除的庫(kù)已恢復(fù)。

四、結(jié)語(yǔ)

MySQL Shell的數(shù)據(jù)恢復(fù)操作有很多可選參數(shù)便于靈活操作,大家可以自己實(shí)操實(shí)驗(yàn)一下。也可以通過(guò)修改并發(fā)參數(shù)來(lái)對(duì)比其他邏輯備份工具的效率。

責(zé)任編輯:姜華 來(lái)源: 數(shù)據(jù)庫(kù)干貨鋪
相關(guān)推薦

2009-04-23 01:00:46

安全恢復(fù)數(shù)據(jù)

2018-12-19 14:03:59

災(zāi)難恢復(fù)RAID陣列

2023-12-13 07:59:04

2017-09-06 08:23:01

數(shù)據(jù)備份恢復(fù)過(guò)程正確姿勢(shì)

2025-02-07 10:52:00

2013-06-08 14:50:10

rman數(shù)據(jù)恢復(fù)

2025-04-28 04:22:00

Spring動(dòng)態(tài)SQL

2019-02-28 21:20:50

MySQL備份與恢復(fù)數(shù)據(jù)庫(kù)

2022-12-01 14:02:02

MySQL數(shù)據(jù)文件

2020-11-09 09:50:45

MySQL數(shù)據(jù)恢復(fù)

2025-04-21 03:30:00

2010-01-14 16:35:31

C++優(yōu)化

2009-03-02 09:29:11

Windows Ser共享資源數(shù)據(jù)恢復(fù)

2022-03-15 09:23:25

mariaDB數(shù)據(jù)恢復(fù)數(shù)據(jù)庫(kù)

2017-07-10 14:26:03

Mysql數(shù)據(jù)備份數(shù)據(jù)恢復(fù)

2024-02-22 08:31:26

數(shù)據(jù)恢復(fù)工具MySQL回滾SQL

2017-12-21 14:36:10

大數(shù)據(jù)健身智慧

2013-10-10 13:36:03

Powershell恢復(fù)

2015-07-28 09:18:27

數(shù)據(jù)保護(hù)數(shù)據(jù)備份數(shù)據(jù)中心

2015-06-04 16:02:08

頂尖數(shù)據(jù)文件亂碼
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)