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

Vue scaffolding learning project creation method

1. What is scaffolding? 1. Vue CLI Vue CLI is a c...

How to understand JS function anti-shake and function throttling

Table of contents Overview 1. Function debounce 2...

Solution to mysql error code 1064

If the words in the sql statement conflict with t...

Conflict resolution when marquee and flash coexist in a page

The main symptom of the conflict is that the FLASH...

The difference between MySQL database host 127.0.0.1 and localhost

Many of my friends may encounter a problem and do...

Summary of commonly used SQL in MySQL operation tables

1. View the types of fields in the table describe...

Detailed tutorial on installing JDK1.8 on Linux

1. Cleaning before installation rpm -qa | grep jd...

Summary of learning HTML tags and basic elements

1. Elements and tags in HTML <br />An eleme...

Detailed explanation of chmod command usage in Linux

chmod Command Syntax This is the correct syntax w...

Web Design Tutorial (5): Web Visual Design

<br />Previous article: Web Design Tutorial ...

3 codes for automatic refresh of web pages

In fact, it is very simple to achieve this effect,...

A brief understanding of the relevant locks in MySQL

This article is mainly to take you to quickly und...

Summary of 6 Linux log viewing methods

As a backend programmer, you deal with Linux in m...