As I understood your question, I think you need to sync 2 databases (A & B) in one SQL server (localhost:3306). I don't know why you need to implementing this. But anyway If you are considering any performance issue, I prefer you to go with database replication
.
Anyhow, For your question refer this https://solutioncenter.apexsql.com/how-to-automatically-keep-two-sql-server-database-schemas-in-sync to get more details.