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

Install and configure MySQL 5.7 under CentOS 7

This article tests the environment: CentOS 7 64-b...

MySQL view principles and basic operation examples

This article uses examples to illustrate the prin...

Introduction to MySQL role functions

Table of contents Preface: 1. Introduction to rol...

Mysql master-slave synchronization configuration scheme under Centos7 system

Preface Recently, when working on a high-availabi...

Why is it not recommended to use an empty string as a className in Vue?

Table of contents Compare the empty string '&...

How to install and uninstall open-vswitch in Linux

1. Compile and install ovs from source code: Inst...

Detailed explanation of commonly used CSS styles (layout)

Compatible with new CSS3 properties In CSS3, we c...

How to implement MySQL bidirectional backup

MySQL bidirectional backup is also called master-...

Why Seconds_Behind_Master is still 0 when MySQL synchronization delay occurs

Table of contents Problem Description Principle A...

A brief analysis of how to set the initial value of Linux root

Ubuntu does not allow root login by default, so t...

Detailed explanation of JavaScript function this pointing problem

Table of contents 1. The direction of this in the...

CentOS 7.2 builds nginx web server to deploy uniapp project

Panther started as a rookie, and I am still a roo...

How to set background color and transparency in Vue

Background color and transparency settings As sho...

Vue implements adding watermark to uploaded pictures

This article shares the specific implementation c...