How to filter out certain libraries during mysql full backup

How to filter out certain libraries during mysql full backup

Use the --all-database parameter when performing a full backup of MySQL

for example:

#mysqldump -u root -h localhost -p --all-database > /root/all.sql

When importing data, you can first log in to the MySQL database and use source /root/all.sql to import.

question:

I want to filter out certain libraries when backing up the database with mysqldump.

In this case, you cannot use --all-database when backing up mysqldump, but use --database instead .

As follows: When backing up the database , filter out the information_schema, mysql, test, and jkhw_db libraries

[root@fangfull-backup ~]# mysql -uroot -p -e "show databases"
Enter password:

+--------------------+
| Database |
+--------------------+
| information_schema |
|hqsb_db|
| jkhw_db |
|mysql |
| test |
| tech_db |
|hqtime_o2o_db|
|hq_o2o_db|
| hqtime_o2o_db_new |
+--------------------+
9 rows in set (0.00 sec)

How to do it:

[root@fangfull-backup ~]# mysql -uroot -p -e "show databases"|grep -Ev "Database|information_schema|mysql|test|jkhw_db"
Enter password:
hqsb_db
tech_db
hqtime_o2o_db
hq_o2o_db
hqtime_o2o_db_new
[root@fangfull-backup ~]# mysql -uroot -p -e "show databases"|grep -Ev "Database|information_schema|mysql|test|jkhw_db"|xargs
Enter password:
hqsb_db tech_db hqtime_o2o_db hq_o2o_db hqtime_o2o_db_new
[root@fangfull-backup ~]# mysql -uroot -p -e "show databases"|grep -Ev "Database|information_schema|mysql|test|jkhw_db"|xargs mysqldump -uroot -p --databases > mysql_dump.sql
Enter password:

The above method of filtering out certain libraries during a complete MySQL backup is all I have to share with you. I hope it can give you a reference, and I also hope that you will support 123WORDPRESS.COM.

You may also be interested in:
  • MySQL complete collapse: detailed explanation of query filter conditions
  • Detailed explanation of MySQL single table query operation examples [syntax, constraints, grouping, aggregation, filtering, sorting, etc.]
  • Detailed explanation of count without filter conditions in MySQL
  • Method for implementing multi-field filtering in Mysql database
  • Summary of MySQL injection bypass filtering techniques
  • MYSQL Must-know Reading Notes Chapter 8: Using Wildcards for Filtering
  • MYSQL Must Know Reading Notes Chapter 7 Data Filtering
  • MYSQL Must Know Reading Notes Chapter 6 Filtering Data
  • MYSQL uses regular expressions to filter data
  • Python connects to MySQL and uses fetchall() method to filter special characters
  • Python implements MySQL single quote string filtering method
  • How to solve mysql replication filter duplication
  • How to dynamically modify the replication filter in mysql

<<:  JavaScript Dom implements the principle and example of carousel

>>:  Detailed explanation of configuring keepalived log to another path in centos7

Recommend

Analysis of MySQL concurrency issues and solutions

Table of contents 1. Background 2. Slow query cau...

Practice of multi-layer nested display of element table

There is a requirement for a list containing mult...

Example of Form action and onSubmit

First: action is an attribute of form. HTML5 has d...

Implementation process of nginx high availability cluster

This article mainly introduces the implementation...

MySQL online deadlock analysis practice

Preface I believe that everyone has had a simple ...

10 bad habits to avoid in Docker container applications

There is no doubt that containers have become an ...

Node uses koa2 to implement a simple JWT authentication method

Introduction to JWT What is JWT The full name is ...

How to implement variable expression selector in Vue

Table of contents Defining the HTML structure Inp...

How to reset the initial value of the auto-increment column in the MySQL table

How to reset the initial value of the auto-increm...

Example code for implementing a pure CSS pop-up menu using transform

Preface When making a top menu, you will be requi...

Detailed explanation of Linux lsof command usage

lsof (list open files) is a tool to view files op...

Docker case analysis: Building a Redis service

Table of contents 1 Create mount directories and ...

MySQL high concurrency method to generate unique order number

Preface After this blog post was published, some ...

HTML form tag tutorial (1):

Forms are a major external form for implementing ...