# Replicate Database for Site Duplication

**URL:** <https://forum.mautic.org/t/replicate-database-for-site-duplication/10101>\
**Category:** General Discussion\
**Created:** [January 3, 2018, 10:41am UTC](https://forum.mautic.org/t/replicate-database-for-site-duplication/10101 "2018-01-03T10:41:55Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![yogesh](https://avatars.discourse-cdn.com/v4/letter/y/49beb7/32.png) [@yogesh](https://forum.mautic.org/u/yogesh)\
**Post date:** [January 3, 2018, 10:41am UTC](https://forum.mautic.org/t/replicate-database-for-site-duplication/10101/1 "2018-01-03T10:41:55Z")

</div>

I tried with taking backup of current database & importing it for the duplicate site, and also made changes in app/config/local.php file accordingly, but didn’t work. It says “Database Connection: Error”, Can anyone help in this ?

---

<div class="post-metadata">

**Author:** ![kgroves](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/kgroves/32/560_2.png) [@kgroves](https://forum.mautic.org/u/kgroves)\
**Post date:** [January 5, 2018, 8:48am UTC](https://forum.mautic.org/t/replicate-database-for-site-duplication/10101/2 "2018-01-05T08:48:20Z")

</div>

That is how I do mine, just make sure you are 100% certain of the connection creds, your MySQL is setup to allow it and that PHP has the required modules to do so.

---

<div class="post-metadata">

**Author:** ![bizcrony](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/bizcrony/32/409_2.png) [@bizcrony](https://forum.mautic.org/u/bizcrony)\
**Post date:** [January 8, 2018, 11:15am UTC](https://forum.mautic.org/t/replicate-database-for-site-duplication/10101/3 "2018-01-08T11:15:19Z")

</div>

you need to migrate database , as per mautic version accordingly, have you done that?

---

<div class="post-metadata">

**Author:** ![yogesh](https://avatars.discourse-cdn.com/v4/letter/y/49beb7/32.png) [@yogesh](https://forum.mautic.org/u/yogesh)\
**Post date:** [January 12, 2018, 6:16am UTC](https://forum.mautic.org/t/replicate-database-for-site-duplication/10101/4 "2018-01-12T06:16:18Z")

</div>

Thank You kgroves for the reply, but it didn’t work for me, again it says “Database Connection: Error”

---

<div class="post-metadata">

**Author:** ![yogesh](https://avatars.discourse-cdn.com/v4/letter/y/49beb7/32.png) [@yogesh](https://forum.mautic.org/u/yogesh)\
**Post date:** [January 12, 2018, 6:19am UTC](https://forum.mautic.org/t/replicate-database-for-site-duplication/10101/5 "2018-01-12T06:19:35Z")

</div>

Thank You Bizcrony for the reply, I need to duplicate the database for site duplication.  
Database Migration as per mautic version is worked for me, but replication of the same is not.

---

<div class="post-metadata">

**Author:** ![petertl](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/petertl/32/511_2.png) [@petertl](https://forum.mautic.org/u/petertl)\
**Post date:** [January 16, 2018, 9:30am UTC](https://forum.mautic.org/t/replicate-database-for-site-duplication/10101/6 "2018-01-16T09:30:34Z")

</div>

Are Mautic and the new database running on the same host machine?

---

<div class="post-metadata">

**Author:** ![yogesh](https://avatars.discourse-cdn.com/v4/letter/y/49beb7/32.png) [@yogesh](https://forum.mautic.org/u/yogesh)\
**Post date:** [January 16, 2018, 9:34am UTC](https://forum.mautic.org/t/replicate-database-for-site-duplication/10101/7 "2018-01-16T09:34:56Z")

</div>

Yes

---

<div class="post-metadata">

**Author:** ![bizcrony](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/bizcrony/32/409_2.png) [@bizcrony](https://forum.mautic.org/u/bizcrony)\
**Post date:** [January 16, 2018, 9:58am UTC](https://forum.mautic.org/t/replicate-database-for-site-duplication/10101/8 "2018-01-16T09:58:40Z")

</div>

@yogesh why dont you install a fresh mautic and use old local.php file …that way you will automatically get old database as you running your mautic presently.

---

<div class="post-metadata">

**Author:** ![petertl](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/petertl/32/511_2.png) [@petertl](https://forum.mautic.org/u/petertl)\
**Post date:** [January 17, 2018, 4:01am UTC](https://forum.mautic.org/t/replicate-database-for-site-duplication/10101/9 "2018-01-17T04:01:12Z")

</div>

YOGESH, are you able to access the server (and database) via MySQL CLI or phpMyAdmin?

---

<div class="post-metadata">

**Author:** ![yogesh](https://avatars.discourse-cdn.com/v4/letter/y/49beb7/32.png) [@yogesh](https://forum.mautic.org/u/yogesh)\
**Post date:** [January 17, 2018, 4:13am UTC](https://forum.mautic.org/t/replicate-database-for-site-duplication/10101/10 "2018-01-17T04:13:10Z")

</div>

@bizcrony I don’t want to use old database, I want to copy old database for duplicate site  
Note: Site duplication means Live site & Staging site, both the sites will have their own respective databases. For now, I have one Live Site & I want to make another site exactly same as my Live site with all data. So, in this way I want to replicate my site.  
However till now, I tried copy database for duplicate site along with changes in Local.php, but it didn’t work.

---

<div class="post-metadata">

**Author:** ![yogesh](https://avatars.discourse-cdn.com/v4/letter/y/49beb7/32.png) [@yogesh](https://forum.mautic.org/u/yogesh)\
**Post date:** [January 17, 2018, 4:15am UTC](https://forum.mautic.org/t/replicate-database-for-site-duplication/10101/11 "2018-01-17T04:15:37Z")

</div>

@petertl Yes I have access to server (and database) via MySQL CLI or phpMyAdmin or adminer.

Note: Site duplication means Live site & Staging site, both the sites will have their own respective databases. For now, I have one Live Site & I want to make another site exactly same as my Live site with all data. So, in this way I want to replicate my site.  
However till now, I tried copy database for duplicate site along with changes in Local.php, but it didn’t work.

---

<div class="post-metadata">

**Author:** ![bizcrony](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/bizcrony/32/409_2.png) [@bizcrony](https://forum.mautic.org/u/bizcrony)\
**Post date:** [January 17, 2018, 4:27am UTC](https://forum.mautic.org/t/replicate-database-for-site-duplication/10101/12 "2018-01-17T04:27:16Z")

</div>

You need to export mysql from phymyadmin

---

<div class="post-metadata">

**Author:** ![petertl](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/petertl/32/511_2.png) [@petertl](https://forum.mautic.org/u/petertl)\
**Post date:** [January 17, 2018, 6:15am UTC](https://forum.mautic.org/t/replicate-database-for-site-duplication/10101/13 "2018-01-17T06:15:06Z")

</div>

YOGESH, I do almost exactly the same what you do. I think the only difference is that - in my case - both production and development/Staging are located on the same server. Here is what I do (host configuration is setup previosly):

1. Dump the production DB with MySQL CLI
2. Copy all Mautic files to another folder in WWW root
3. Create an empty DB
4. Restore the DB dump into the new DB
5. Modify app/config/local.php:
  - DB name (the new one)
  - Site URL
  - Directories (cache, log)

6. Just to be sure: CHOWN and CHMOD everything as it has to be
7. Clear application cache

If both Mautic app and DB are on the same host, you don’t need to modify the DB host (use “localhost”).

Topic phpMyAdmin: You can dump your DB with phpMyAdmin, but you better not use it to restore. As your application data grow, you will shortly run into performance/timeout issues.

---

<div class="post-metadata">

**Author:** ![namratasaun](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/namratasaun/32/2801_2.png) [@namratasaun](https://forum.mautic.org/u/namratasaun)\
**Post date:** [December 28, 2020, 3:16am UTC](https://forum.mautic.org/t/replicate-database-for-site-duplication/10101/14 "2020-12-28T03:16:03Z")

</div>

how to open phpmyadmin. I am new to mautic
