Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL database sync betwen two servers using PHP

I have the same website on two different servers.
Master Database - server1
Slave Database - Server2

I want to make PHP script which will check for changes in master database and if found any it will syncronize it with slave database. I will set chronjob for that script so it will run every few minutes.

I found some scripts on Google but it doesn't work at all. I tried using PMS but I'm receiving:

Notice: Use of undefined constant host - assumed 'host' in /var/www/demos/pms/pmslib.php on line 57
Notice: Use of undefined constant user - assumed 'user' in /var/www/demos/pms/pmslib.php on line 57
Notice: Use of undefined constant pass - assumed 'pass' in /var/www/demos/pms/pmslib.php on line 57
Notice: Use of undefined constant base - assumed 'base' in /var/www/demos/pms/pmslib.php on line 63
Notice: Use of undefined constant host - assumed 'host' in /var/www/demos/pms/pmslib.php on line 79
Notice: Use of undefined constant host - assumed 'host' in /var/www/demos/pms/pmslib.php on line 57
Notice: Use of undefined constant user - assumed 'user' in /var/www/demos/pms/pmslib.php on line 57
Notice: Use of undefined constant pass - assumed 'pass' in /var/www/demos/pms/pmslib.php on line 57
Notice: Use of undefined constant base - assumed 'base' in /var/www/demos/pms/pmslib.php on line 63
Notice: Use of undefined constant host - assumed 'host' in /var/www/demos/pms/pmslib.php on line 79

like image 301
xZero Avatar asked Nov 04 '12 04:11

xZero


1 Answers

You may not need to use PHP at all for this. MySQL has replication capabilities built into it that can be turned on. See chapter 16 of the MySQL manual - http://dev.mysql.com/doc/refman/5.0/en/replication.html

like image 160
Tim Dearborn Avatar answered Sep 28 '22 08:09

Tim Dearborn