Instances of excluding certain libraries when backing up the database with mysqldump

Instances of excluding certain libraries when backing up the database with mysqldump

illustrate:

Using mysqldump –all-databases will export all libraries. But if we are doing master-slave, when dumping data from the master database, we do not need or want the information_schema and mysql libraries. If there are few databases, you can export them through /usr/local/mysql/bin/mysqldump -uroot -p --databases db1 db2 > db1db2.sql. However, if there are a lot of data, it will be troublesome to specify it in this way.

MySQL supports ignore-table, but not ignore-database. So if we want to export all libraries except information_schema and mysql, can we only specify databases one by one?

solve:

# mysql -e "show databases;" -uroot -p| grep -Ev "Database|information_schema|mysql|test" | xargs mysqldump -uroot -p --databases > mysql_dump.sql

appendix:

Appendix 1: mysqldump: Got error: 1142: SELECT,LOCK TABL command denied to user 'root'@'localhost' for table 'cond_instances' when using LOCK TABLES

In MySQL 5.5, performance_schema was added. When we perform mysqldump, the following error message will be reported:

mysqldump: Got error: 1142: SELECT,LOCK TABL command denied to user 'root'@'localhost' for table 'cond_instances' when using LOCK TABLES

We can add the parameter --skip-lock-tables to mysqldump, such as

# mysqldump -uroot -p --skip-lock-tables performance_schema > performance_schema.sql or filter out the performance_schema library

# mysql -e "show databases;" -uroot -p| grep -Ev "Database|information_schema|mysql|test|performance_schema" | xargs mysqldump -uroot -p --databases > mysql_dump.sql

The above example of excluding certain libraries when backing up the database with mysqldump is all I have to share with you. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM.

You may also be interested in:
  • PHP scheduled backup MySQL and mysqldump syntax parameters detailed
  • Things to note when backing up data with mysqldump plus the -w parameter
  • Detailed explanation of mysqldump database backup parameters
  • Implementation of MySQL5.7 mysqldump backup and recovery
  • Summary of MySql import and export methods using mysqldump
  • Detailed explanation of the use of MySQL mysqldump
  • Docker uses the mysqldump command to back up and export mysql data in the project
  • MySQL data migration using MySQLdump command
  • Comparison of mydumper and mysqldump in mysql
  • Detailed explanation of Linux mysqldump exporting database, data, and table structure
  • Detailed discussion on the issue of mysqldump data export
  • A brief discussion on how to use mysqldump (MySQL database backup and recovery)
  • mysqldump parameters you may not know

<<:  Implementation example of video player based on Vue

>>:  Nginx learning how to build a file hotlink protection service example

Recommend

JavaScript using Ckeditor + Ckfinder file upload case detailed explanation

Table of contents 1. Preparation 2. Decompression...

Web Design Experience: Efficiently Writing Web Code

Originally, this seventh chapter should be a deep ...

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

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

How to install JDK 13 in Linux environment using compressed package

What is JDK? Well, if you don't know this que...

5 cool and practical HTML tags and attributes introduction

In fact, this is also a clickbait title, and it c...

MySQL compression usage scenarios and solutions

Introduction Describes the use cases and solution...

JavaScript event delegation principle

Table of contents 1. What is event delegation? 2....

Solutions to MySql crash and service failure to start

I have been in contact with PHP for so long, but ...

JavaScript implements password box verification information

This article example shares the specific code of ...

About the problems of congruence and inequality, equality and inequality in JS

Table of contents Congruent and Incongruent congr...

Knowledge about MySQL Memory storage engine

Knowledge points about Memory storage engine The ...

Implement QR code scanning function through Vue

hint This plug-in can only be accessed under the ...

The implementation process of extracting oracle data to mysql database

In the migration of Oracle database to MySQL data...

Explanation of the steps for Tomcat to support https access

How to make tomcat support https access step: (1)...