Hi I am trying to synchronize my local mysql database to the web server. Please help me how to do it

January 17, 2019 1.1k views
PHP Frameworks Deployment Automated Setups API Databases Development

We have developed an ERP application which should run in a LAN network, when we make any entries it should be stored in the local DB first then updated in the web server DB. If there is no internet connection still the entries needs to be saved in the local dB and then when the internet is back it should automatically updated in the web dB.

Please help me with the steps of how to do it.

3 Answers

@srinath1989

You need to setup a master/slave replication between your local DB and the server’s DB. this tutorial helps to get it done.

by Etel Sverdlov
MySQL replication is a process that allows you to easily maintain multiple copies of a MySQL data by having them copied automatically from a master to a slave database. This can helpful for many reasons including facilating a backup for the data,a way to analyze it without using the main database, or simply as a means to scale out. This tutorial will cover a very simple example of mysql replication—one master will send information to a single slave.
  • Hi thanks for the response, one more question. I am using a windows 10 OS in my local system and server is linus, how do I configure master slave between windows and linux. Also we do not have a static IP, can we do the same using public IP.

If you are using Microsoft SQL server on windows then I have no idea how to replicate from it to Linux but maybe same instructions can work, however if you are using mysql on windows then it is the same.

As for the second question the Linux server which is the replication slave needs to connect to Windows which is the replication master, so you need to provide it with either an IP address on your router and setup port forwarding from the router to your Windows however this needs a fixed public IP address, if you cannot get it I think you can setup VPN server on Linux and then setup your router as a VPN client then you can connect from the server to windows using its private IP address which you can easily control it.

Sorry for making this too long but I hope it helps out, if you still have any other questions please do not hesitate to write back here.

Mouhsen Ibrahim

  • Hi Mohsen, thank you for the feedback will try the Public IP address and VPN method then let you know if it works.

A simple guide for setting up your first web server. you will only cover PHP, MySQL database and Apache webserver.

Have another answer? Share your knowledge.