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

How to implement scheduled backup of MySQL database

1. Create a shell script vim backupdb.sh Create t...

Use Docker to build a Redis master-slave replication cluster

In a cluster with master-slave replication mode, ...

5 tips for writing CSS to make your style more standardized

1. Arrange CSS in alphabetical order Not in alphab...

JavaScript implements circular progress bar effect

This article example shares the specific code of ...

A brief analysis of the responsiveness principle and differences of Vue2.0/3.0

Preface Since vue3.0 was officially launched, man...

Bootstrap 3.0 study notes for beginners

As the first article of this study note, we will ...

Detailed explanation of the benefits of PNG in various network image formats

BMP is an image file format that is independent o...

HTML basic structure_Powernode Java Academy

Many times when learning web page development, th...

Vue+thinkphp5.1+axios to realize file upload

This article shares with you how to use thinkphp5...

Implementing a simple age calculator based on HTML+JS

Table of contents Preface Demonstration effect HT...

Bootstrap 3.0 learning notes button style

This article mainly explains the style of buttons...

Detailed explanation of basic concepts of HTML

What is HTML? HTML is a language used to describe...

How to implement gzip compression in nginx to improve website speed

Table of contents Why use gzip compression? nginx...

mysql replace part of the field content and mysql replace function replace()

[mysql] replace usage (replace part of the conten...