# How to add new database to existing master slave replication in mysql 8

**URL:** <https://forums.percona.com/t/how-to-add-new-database-to-existing-master-slave-replication-in-mysql-8/15683>\
**Category:** Percona Server for MySQL 8.0\
**Created:** [May 13, 2022, 2:38pm UTC](https://forums.percona.com/t/how-to-add-new-database-to-existing-master-slave-replication-in-mysql-8/15683 "2022-05-13T14:38:13Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![ulka01](https://avatars.discourse-cdn.com/v4/letter/u/77aa72/32.png) [@ulka01](https://forums.percona.com/u/ulka01)\
**Post date:** [May 13, 2022, 2:38pm UTC](https://forums.percona.com/t/how-to-add-new-database-to-existing-master-slave-replication-in-mysql-8/15683/1 "2022-05-13T14:38:13Z")

</div>

I have an existing percona mysql 8.0.26 master-slave configuration in place.  
How do I add a new database to be replicated to the slave.  
Are there any steps or has anyone created. Please share.

---

<div class="post-metadata">

**Author:** ![matthewb](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/matthewb/32/34_2.png) [@matthewb](https://forums.percona.com/u/matthewb)\
**Post date:** [May 13, 2022, 5:53pm UTC](https://forums.percona.com/t/how-to-add-new-database-to-existing-master-slave-replication-in-mysql-8/15683/2 "2022-05-13T17:53:11Z")

</div>

On the source MySQL, simply create the database `CREATE DATABASE IF NOT EXISTS myDatabase` and that will replicate to the replica and be executed. Make sure replication is indeed running by `SHOW REPLICA STATUS\G` on the replica.

---

<div class="post-metadata">

**Author:** ![ulka01](https://avatars.discourse-cdn.com/v4/letter/u/77aa72/32.png) [@ulka01](https://forums.percona.com/u/ulka01)\
**Post date:** [May 23, 2022, 3:14pm UTC](https://forums.percona.com/t/how-to-add-new-database-to-existing-master-slave-replication-in-mysql-8/15683/3 "2022-05-23T15:14:13Z")

</div>

I have a percona master-slave 8.0.26  
The solution that you say, not sure will work.  
Will it need xtrabackup, parameter changes and restore the backup?

---

<div class="post-metadata">

**Author:** ![matthewb](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/matthewb/32/34_2.png) [@matthewb](https://forums.percona.com/u/matthewb)\
**Post date:** [May 23, 2022, 4:06pm UTC](https://forums.percona.com/t/how-to-add-new-database-to-existing-master-slave-replication-in-mysql-8/15683/4 "2022-05-23T16:06:23Z")

</div>

> [@ulka01](#):
>
> How do I add a new database to be replicated to the slave.

You asked how to add a new database which will be replicated to the slave. This question implies that you already have replication setup. If you already have replication configured, then you don’t need xtrabackup. You would have already used xtrabackup to create the slave in the first place. Once replication is running, creating a database is simple SQL as I explained above.

---

<div class="post-metadata">

**Author:** ![ulka01](https://avatars.discourse-cdn.com/v4/letter/u/77aa72/32.png) [@ulka01](https://forums.percona.com/u/ulka01)\
**Post date:** [May 23, 2022, 9:13pm UTC](https://forums.percona.com/t/how-to-add-new-database-to-existing-master-slave-replication-in-mysql-8/15683/5 "2022-05-23T21:13:27Z")

</div>

Aha, probably I put the wrong question then.  
Yes agreed I have a replication setup, but now I want to replicate a new database to the slave.  
It would be nice if you can help me to get the exact steps for this case.

---

<div class="post-metadata">

**Author:** ![matthewb](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/matthewb/32/34_2.png) [@matthewb](https://forums.percona.com/u/matthewb)\
**Post date:** [May 24, 2022, 2:43am UTC](https://forums.percona.com/t/how-to-add-new-database-to-existing-master-slave-replication-in-mysql-8/15683/6 "2022-05-24T02:43:37Z")

</div>

> [@ulka01](#):
>
> Yes agreed I have a replication setup

This means that you already have a working master and slave.

> [@ulka01](#):
>
> but now I want to replicate a new database to the slave

Yes, go to the master and `CREATE DATABASE myNewDatabase`

---

<div class="post-metadata">

**Author:** ![ulka01](https://avatars.discourse-cdn.com/v4/letter/u/77aa72/32.png) [@ulka01](https://forums.percona.com/u/ulka01)\
**Post date:** [June 2, 2022, 11:23am UTC](https://forums.percona.com/t/how-to-add-new-database-to-existing-master-slave-replication-in-mysql-8/15683/7 "2022-06-02T11:23:48Z")

</div>

I created new database on the master, but it doesn’t show on the slave.  
I updated my.cnf on the slave with replicate-do-db = test.  
And restarted the slave mysql service.  
But I can’t see the database on slave.  
Instead I see an error on slave.  
Last\_Error: Coordinator stopped because there were error(s) in the worker(s). The most recent failure being: Worker 1 failed executing transaction ‘d0305618-e25d-11ec-aa88-005056ab077e:4’ at master log mysql-bin.000003, end\_log\_pos 857.

---

<div class="post-metadata">

**Author:** ![matthewb](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/matthewb/32/34_2.png) [@matthewb](https://forums.percona.com/u/matthewb)\
**Post date:** [June 2, 2022, 1:18pm UTC](https://forums.percona.com/t/how-to-add-new-database-to-existing-master-slave-replication-in-mysql-8/15683/8 "2022-06-02T13:18:03Z")

</div>

> [@ulka01](#):
>
> replicate-do-db = test

You do not need this. Replication, by default, replicates everything. There is nothing you need to add to my.cnf.

> [@ulka01](#):
>
> Last\_Error: Coordinator stopped because there were error(s) in the worker(s)

_THIS_ is your problem. Replication was not configured correctly to start with. Right now, your replication is broken. You need to resolve this issue and get replication running properly. Then your database will show up. I suggest you wipe the slave and start over.

---

<div class="post-metadata">

**Author:** ![ulka01](https://avatars.discourse-cdn.com/v4/letter/u/77aa72/32.png) [@ulka01](https://forums.percona.com/u/ulka01)\
**Post date:** [June 2, 2022, 2:20pm UTC](https://forums.percona.com/t/how-to-add-new-database-to-existing-master-slave-replication-in-mysql-8/15683/9 "2022-06-02T14:20:16Z")

</div>

Could you please suggest a document to follow

---

<div class="post-metadata">

**Author:** ![ulka01](https://avatars.discourse-cdn.com/v4/letter/u/77aa72/32.png) [@ulka01](https://forums.percona.com/u/ulka01)\
**Post date:** [June 2, 2022, 2:21pm UTC](https://forums.percona.com/t/how-to-add-new-database-to-existing-master-slave-replication-in-mysql-8/15683/10 "2022-06-02T14:21:07Z")

</div>

Could you please suggest a document to built master-slave replication

---

<div class="post-metadata">

**Author:** ![ulka01](https://avatars.discourse-cdn.com/v4/letter/u/77aa72/32.png) [@ulka01](https://forums.percona.com/u/ulka01)\
**Post date:** [June 2, 2022, 2:25pm UTC](https://forums.percona.com/t/how-to-add-new-database-to-existing-master-slave-replication-in-mysql-8/15683/11 "2022-06-02T14:25:05Z")

</div>

I am trying to build a GTID based master slave replication.

---

<div class="post-metadata">

**Author:** ![Wayne\_Leutwyler](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/wayne_leutwyler/32/20829_2.png) [@Wayne\_Leutwyler](https://forums.percona.com/u/Wayne_Leutwyler)\
**Post date:** [June 2, 2022, 2:37pm UTC](https://forums.percona.com/t/how-to-add-new-database-to-existing-master-slave-replication-in-mysql-8/15683/12 "2022-06-02T14:37:15Z")

</div>

Check this out: [Search Percona.com](https://www.percona.com/search?s=setup+replication)

---

<div class="post-metadata">

**Author:** ![ulka01](https://avatars.discourse-cdn.com/v4/letter/u/77aa72/32.png) [@ulka01](https://forums.percona.com/u/ulka01)\
**Post date:** [June 2, 2022, 8:38pm UTC](https://forums.percona.com/t/how-to-add-new-database-to-existing-master-slave-replication-in-mysql-8/15683/13 "2022-06-02T20:38:29Z")

</div>

Thanks, I have configured now master-slave replication.  
And this way I am replicating all the databases to the slave.  
However it seems, I have to read about replicate\_do\_db for adding specific databases to slave and how to add new one to this specific list.  
Thanks again.

---

<div class="post-metadata">

**Author:** ![matthewb](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/matthewb/32/34_2.png) [@matthewb](https://forums.percona.com/u/matthewb)\
**Post date:** [June 2, 2022, 9:36pm UTC](https://forums.percona.com/t/how-to-add-new-database-to-existing-master-slave-replication-in-mysql-8/15683/14 "2022-06-02T21:36:43Z")

</div>

> [@ulka01](#):
>
> replicate\_do\_db for adding specific databases to slave and how to add new one to this specific list

No! As I said above **everything replicates by default**! You do **NOT** need to add this parameter each time you make a new database. When you `CREATE DATABASE foo` that database will AUTOMATICALLY be replicated by default.

replicate\_do\_db is a parameter to use when you want to restrict which databases are replicated which is a _very very advanced_ way to run MySQL replication.

---

<div class="post-metadata">

**Author:** ![palak231](https://avatars.discourse-cdn.com/v4/letter/p/b38774/32.png) [@palak231](https://forums.percona.com/u/palak231)\
**Post date:** [June 10, 2022, 8:37am UTC](https://forums.percona.com/t/how-to-add-new-database-to-existing-master-slave-replication-in-mysql-8/15683/15 "2022-06-10T08:37:35Z")

</div>

Hi  
@matthewb I was also expecting same answer. Just expected reply.

Thanks

---

<div class="post-metadata">

**Author:** ![OracleJavaNet](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/oraclejavanet/32/1261_2.png) [@OracleJavaNet](https://forums.percona.com/u/OracleJavaNet)\
**Post date:** [August 31, 2022, 7:23pm UTC](https://forums.percona.com/t/how-to-add-new-database-to-existing-master-slave-replication-in-mysql-8/15683/16 "2022-08-31T19:23:04Z")

</div>

When you mention **everything replicates by default** , does that include _mysql_, _sys_, _information\_schema_, and _performance\_schema_? I’ve used the _replicate\_do\_db_ replication filter in the past since it wasn’t clear “what” was going to be replicated on the slave/replica.

---

<div class="post-metadata">

**Author:** ![matthewb](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/matthewb/32/34_2.png) [@matthewb](https://forums.percona.com/u/matthewb)\
**Post date:** [August 31, 2022, 8:15pm UTC](https://forums.percona.com/t/how-to-add-new-database-to-existing-master-slave-replication-in-mysql-8/15683/17 "2022-08-31T20:15:51Z")

</div>

> When you mention **everything replicates by default** , does that include _mysql_, _sys_, _information\_schema_, and _performance\_schema_?

**EVERYTHING** REPLICATES BY DEFAULT! **EVERYTHING**! **E-V-E-R-Y-T-H-I-N-G**!

Every database, every table, every column… everything replicates by default!

---

<div class="post-metadata">

**Author:** ![Wojciech\_Niemira](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/wojciech_niemira/32/6695_2.png) [@Wojciech\_Niemira](https://forums.percona.com/u/Wojciech_Niemira)\
**Post date:** [October 30, 2022, 2:01pm UTC](https://forums.percona.com/t/how-to-add-new-database-to-existing-master-slave-replication-in-mysql-8/15683/18 "2022-10-30T14:01:08Z")

</div>

Yes, all databases are replicated by default, even the new ones. However, when in my.cnf we define which databases are to be replicated (parameter ‘binlog\_do\_db’), then creating a new database on the master will not create it on the slave. And this is what the author of this post asked for sure. I have the same problem to solve and I intend to solve it in the next few days.

---

<div class="post-metadata">

**Author:** ![matthewb](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/matthewb/32/34_2.png) [@matthewb](https://forums.percona.com/u/matthewb)\
**Post date:** [October 30, 2022, 4:27pm UTC](https://forums.percona.com/t/how-to-add-new-database-to-existing-master-slave-replication-in-mysql-8/15683/19 "2022-10-30T16:27:38Z")

</div>

> [@Wojciech\_Niemira](#):
>
> then creating a new database on the master will not create it on the slave

Correct! Because setting binlog\_do\_db **overrides** the default behavior. Stop using this setting if you want to replicate all databases, current and future.

---

<div class="post-metadata">

**Author:** ![Fborgoglio71](https://avatars.discourse-cdn.com/v4/letter/f/53a042/32.png) [@Fborgoglio71](https://forums.percona.com/u/Fborgoglio71)\
**Post date:** [June 6, 2025, 3:45pm UTC](https://forums.percona.com/t/how-to-add-new-database-to-existing-master-slave-replication-in-mysql-8/15683/20 "2025-06-06T15:45:33Z")

</div>

Hi.  
I have the same problem.  
I had not binlog\_do\_db set,  
replica looks good but i can’t see the db created in master when I run show databases on slave.

[Next page](https://forums.percona.com/t/how-to-add-new-database-to-existing-master-slave-replication-in-mysql-8/15683.md?page=2)
