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
The code under the easyui framework is as follows...
When installing a virtual machine, a prompt appea...
I usually like to visit the special pages or prod...
Preface: As a giant in the IT industry, Microsoft...
A while ago, I wrote a blog post titled "Can...
What is the reason for the Last_IO_Errno:1236 err...
In fact, there are many corresponding writing met...
Preface This article mainly introduces the releva...
When you first start using Docker, you will inevi...
Table of contents 1. What is a subquery? 2. Where...
"The great river flows eastward, the waves w...
Last night I wrote an essay about the browser ren...
SQL is the main trunk. Why do I understand it thi...
Table of contents <template> <ul class=&...
Treemaps are mainly used to visualize tree-like d...