sunil sandeep
sunil sandeep

Reputation: 21

running the same database both local and online in mysql

I am creating a software for my client in PHP and MySql, The software will be running in the local network, the software should also run in online that is all the data should be viewed online, i would like to know is there a way to update the mysql database from local to online whenever the internet is connected, if the internet is not connected all the data will be stored in local mysql server. they wont be adding any data in the online server and they will only view the contents. Kindly help me in this

Upvotes: 0

Views: 2466

Answers (4)

Ela Buwa
Ela Buwa

Reputation: 1704

I would suggest you setup master/slave replication. I would make the local server the master and the internet server the slave. However, if you are using a common shared hosting service, I am not too sure if you have permission to setup such DB replication structure.

Tryhttps://www.digitalocean.com/community/articles/how-to-set-up-master-slave-replication-in-mysql. However, with the mysql versions pre 5.6 (I think) you can't delay the replication from a predefined interval. However, http://alexalexander.blogspot.com/2013/03/mysql-slave-delay-how-to.html suggests using something called a percona tool kit. I haven't used it though.

Upvotes: 0

Rob
Rob

Reputation: 12872

Setup replication between your mysql databases. The local network database would be the slave and the web server would be the master.

See http://dev.mysql.com/doc/refman/5.5/en/replication-howto.html for setting up replication.

Upvotes: 0

Brett Poole
Brett Poole

Reputation: 31

It sounds like you are looking for a way to have a read-only, "online" (assuming WAN) MySQL server which is updated from a read-write, "offline" (LAN) MySQL Server which is updated by your users.

If that's the case, you may want to consider a Master/Slave MySQL Replication configuration: http://www.rackspace.com/knowledge_center/article/mysql-replication-masterslave

Upvotes: 1

Zahidul Hossein Ripon
Zahidul Hossein Ripon

Reputation: 672

you can run a cron job in your local server which monitor and upload data to online server when internet is available. You need to track (set a status) which data is uploaded which not for synchronization

Upvotes: 0

Related Questions