Description:
The mysqldump backs up databases bak_1 and bak_2. The third line comment in the result file contains the information 'Database: bak_1', while bak_2 is missing.
-- Host: localhost Database: bak1(while bak_2 is missing)
How to repeat:
1- Create user for backup:
create user 'u_bak'@'%' identified with mysql_native_password by '*****';
2- Configure appropriate permissions:
grant select,reload,process,lock tables,replication client,replication_slave_admin,show view,trigger on *.* to 'u_bak'@'%';
3- Create two test databases:
mysql> create database bak1;
Query OK, 1 row affected (0.01 sec)
mysql> create database bak2;
Query OK, 1 row affected (0.01 sec)
4:The creation of two test tables respectively:
mysql> create table bak1.t1(id int not null auto_increment,a varchar(20) default null,b int default null,c datetime not null default current_timestamp,primary key (id)) engine=innodb charset=utf8mb4;
mysql> create table bak1.t2 like bak1.t1;
Query OK, 0 rows affected (0.02 sec)
mysql> create table bak2.t1 like bak1.t1;
Query OK, 0 rows affected (0.02 sec)
mysql> create table bak2.t2 like bak1.t1;
Query OK, 0 rows affected (0.02 sec)
5:The insertion of test data:
mysql> insert into bak1.t1(a,b) values ('one',1),('two',2);
Query OK, 2 rows affected (0.00 sec)
Records: 2 Duplicates: 0 Warnings: 0
mysql> insert into bak1.t2(a,b) select a,b from bak1.t1;
Query OK, 2 rows affected (0.01 sec)
Records: 2 Duplicates: 0 Warnings: 0
mysql> insert into bak2.t1(a,b) select a,b from bak1.t1;
Query OK, 2 rows affected (0.01 sec)
Records: 2 Duplicates: 0 Warnings: 0
mysql> insert into bak2.t2(a,b) select a,b from bak1.t1;
Query OK, 2 rows affected (0.01 sec)
Records: 2 Duplicates: 0 Warnings: 0
6- The backup of multiple databases:
[mysql@Mysql01 data]$ mysqldump -u u_bak -p'*****' -B bak1 bak2 >bak1_bak2.sql
7- The validation of the generated result file content:
[mysql@Mysql01 data]$ cat bak1_bak2.sql
-- MySQL dump 10.13 Distrib 8.0.36, for Linux (x86_64)
--
-- Host: localhost Database: bak1
-- ------------------------------------------------------
-- Server version 8.0.36
Suggested fix:
The content of the result file is inaccurate! Fix by adding the missing bak2 information to the third line of the .sql result file.
Accurate information example:
[mysql@Mysql01 data]$ cat bak1_bak2.sql
-- MySQL dump 10.13 Distrib 8.0.36, for Linux (x86_64)
--
-- Host: localhost Database: bak1 bak2
-- ------------------------------------------------------
-- Server version 8.0.36