# How do I pt-table-sync all tables from one localhost database to another?

**URL:** <https://forums.percona.com/t/how-do-i-pt-table-sync-all-tables-from-one-localhost-database-to-another/4668>\
**Category:** Percona Toolkit\
**Created:** [January 15, 2016, 1:48pm UTC](https://forums.percona.com/t/how-do-i-pt-table-sync-all-tables-from-one-localhost-database-to-another/4668 "2016-01-15T13:48:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Engineer10](https://avatars.discourse-cdn.com/v4/letter/e/839c29/32.png) [@Engineer10](https://forums.percona.com/u/Engineer10)\
**Post date:** [January 15, 2016, 1:48pm UTC](https://forums.percona.com/t/how-do-i-pt-table-sync-all-tables-from-one-localhost-database-to-another/4668/1 "2016-01-15T13:48:57Z")

</div>

I have two databases on localhost: db1 and db2. I want to pt-table-sync all tables on db2 to be exactly like their equivalents on db1. I tried the following command line:

```auto
$ pt-table-sync --dry-run h=localhost,u=user,p=pass,d=db1 h=localhost,u=user,p=pass,d=db2

```

This failed with the following error:

```auto
you specified a database but not a table in h=localhost,u=user,p=pass,d=db1. are you trying to sync only tables in the 'db1' database? if so, use '--databases db1' instead.

```

I also tried dropping the D part of both DSNs, and instead specify

```auto
--databases=db1,db2

```

This shows zero differences, even though in reality differences do exist. I’m guessing what it does is compare each database to itself.

Is there a way to do this with pt-table-sync?

---

<div class="post-metadata">

**Author:** ![volkimd](https://avatars.discourse-cdn.com/v4/letter/v/7cd45c/32.png) [@volkimd](https://forums.percona.com/u/volkimd)\
**Post date:** [March 20, 2018, 3:47am UTC](https://forums.percona.com/t/how-do-i-pt-table-sync-all-tables-from-one-localhost-database-to-another/4668/2 "2018-03-20T03:47:12Z")

</div>

Hi,

I have the same topic. I want to Sync all Tables of DB named ABC on Host A to DB CBA on Host B. In this case I want to replicate from a TestDB to ProdDB, no master-slave concept.  
I got the same results as above. Is there another way to realize this, maybe with wildcards or another Tool as pt-table-sync?

Regards

---

<div class="post-metadata">

**Author:** ![carlos.salguero](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/carlos.salguero/32/20_2.png) [@carlos.salguero](https://forums.percona.com/u/carlos.salguero)\
**Post date:** [March 20, 2018, 7:11am UTC](https://forums.percona.com/t/how-do-i-pt-table-sync-all-tables-from-one-localhost-database-to-another/4668/3 "2018-03-20T07:11:51Z")

</div>

Hi,

Using [COLOR=#FF0000] should work. If there are no differences, you might try using a different checksum algorithm.  
See [URL][[PT-187] pt-table-checksum not able to get differences for columns - Percona JIRA](https://jira.percona.com/browse/PT-187%5B/URL%5D) for a complete explanation.

Regards

---

<div class="post-metadata">

**Author:** ![carlos.salguero](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/carlos.salguero/32/20_2.png) [@carlos.salguero](https://forums.percona.com/u/carlos.salguero)\
**Post date:** [March 20, 2018, 7:30am UTC](https://forums.percona.com/t/how-do-i-pt-table-sync-all-tables-from-one-localhost-database-to-another/4668/4 "2018-03-20T07:30:05Z")

</div>

Answering the second question:  
You can sync to a different database by specifying the source Database and Table in the first DSN, but only the db in the destination DSN.  
Example:

I have the table test.t1 in the instance running at port 12345 and I want to copy it to the database test2 in the instance running at port 12346

> [@](#):
>
> pt-table-sync h=127.0.0.1,P=12345,u=msandbox,p=msandbox,D=test,t=t1 h=127.0.0.1,P=12346,u=msandbox,p=msandbox,D=test2 --execute

---

<div class="post-metadata">

**Author:** ![volkimd](https://avatars.discourse-cdn.com/v4/letter/v/7cd45c/32.png) [@volkimd](https://forums.percona.com/u/volkimd)\
**Post date:** [March 20, 2018, 7:46am UTC](https://forums.percona.com/t/how-do-i-pt-table-sync-all-tables-from-one-localhost-database-to-another/4668/5 "2018-03-20T07:46:45Z")

</div>

Hi,

thank you for your answer.

I’ve checked this topics. Pt-table-checksum can’t sync across different Hosts if I don’t run a Master - Slave approach, which doesn’t make sense in this case. Pt-table-sync is working perfect for a defined number of tables, but there is no solution for all tables.

Regards
