In the official MySQL dump tool, how can I restore only a certain database? Full database backup [root@HE1 ~]# mysqldump -uroot -p --single-transaction -A --master-data=2 >dump.sql Only restore the contents of the erp library [root@HE1 ~]# mysql -uroot -pMANAGER erp --one-database <dump.sql It can be seen that the main parameter used here is the --one-database abbreviated as -o, which greatly facilitates our recovery flexibility. So how do we extract a table from the full database backup? Restoring the entire database and then restoring a table is OK for a small database, but it is very troublesome for a large database. Then we can use regular expressions for quick extraction. The specific implementation method is as follows: Extract the table structure of table t from the full database backup [root@HE1 ~]# sed -e'/./{H;$!d;}' -e 'x;/CREATE TABLE `t`/!d;q' dump.sql DROP TABLE IF EXISTS `t`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `t` ( `id` int(10) NOT NULL AUTO_INCREMENT, `age` tinyint(4) NOT NULL DEFAULT '0', `name` varchar(30) NOT NULL DEFAULT '', PRIMARY KEY (`id`) )ENGINE=InnoDBAUTO_INCREMENT=4 DEFAULT CHARSET=utf8; /*!40101 SETcharacter_set_client = @saved_cs_client */; Extract the contents of the t table from the full database backup [root@HE1 ~]# grep'INSERT INTO `t`' dump.sql INSERT INTO `t`VALUES (0,0,''),(1,0,'aa'),(2,0,'bbb'),(3,25,'helei'); The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: Vue mobile terminal realizes finger sliding effect
>>: How to solve the problem of character set when logging in to Linux
1. 85% of ads go unread <br />Interpretatio...
Preface Because this is a distributed file system...
Table of contents Registering Components Adding C...
1. Disk partition: 2. fdisk partition If the disk...
In most cases, MySQL does not support Chinese whe...
MySQL 4.x and above provide full-text search supp...
Sometimes you need to set several areas on a pict...
1. For comparison of date size, the date format p...
Deploy the project to the project site test envir...
A few days ago, I discovered that my website was ...
This article describes how to use the local yum s...
Table of contents Introduction Traditional transi...
The webpage displays 403 Forbidden Nginx (yum ins...
Table of contents 1. Analyzing MySQL from a macro...
Table of contents 1. Scenario 2. Basic functions ...