{"id":2179,"date":"2013-07-07T14:15:25","date_gmt":"2013-07-07T06:15:25","guid":{"rendered":"http:\/\/rmohan.com\/?p=2179"},"modified":"2013-07-07T14:15:25","modified_gmt":"2013-07-07T06:15:25","slug":"setup-mysql-replication-between-linuxmaster-windows-xpslave","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=2179","title":{"rendered":"Setup Mysql Replication Between Linux(master) &#038; Windows XP(Slave)"},"content":{"rendered":"<p><strong>Step 1 \u2013 Configure the Master Server<\/strong><\/p>\n<p>First we have to edit\u00a0\/etc\/mysql\/my.cnf. We have to enable networking for MySQL, and MySQL should listen on all IP addresses, therefore we comment out these lines (if existant):<\/p>\n<p>#skip-networking<\/p>\n<p>#bind-address\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0= 127.0.0.1<\/p>\n<p>Furthermore we have to tell MySQL for which database it should write logs (these logs are used by the slave to see what has changed on the master),<\/p>\n<p>which log file it should use, and we have to specify that this MySQL server is the master. We want to replicate the database\u00a0exampledb, so<\/p>\n<p>we put the following lines into\/etc\/mysql\/my.cnf:<\/p>\n<p>server-id\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0= 1<\/p>\n<p>log_bin\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0= \/var\/log\/mysql\/mysql-bin.log<\/p>\n<p>binlog_do_db\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0= exampledb<\/p>\n<p>&nbsp;<\/p>\n<p>Then we restart MySQL:<\/p>\n<p>\/etc\/init.d\/mysql restart<\/p>\n<p>Then we log into the MySQL database as\u00a0root\u00a0and create a user with replication privileges:<\/p>\n<p>&nbsp;<\/p>\n<p>mysql -u root -p<\/p>\n<p>Enter password:<\/p>\n<p>&nbsp;<\/p>\n<p>Now we are on the MySQL shell.<\/p>\n<p>mysql&gt;GRANT REPLICATION SLAVE ON *.* TO \u2019slave_user\u2019@\u2019%\u2019 IDENTIFIED BY \u2018&lt;some_password&gt;\u2019;\u00a0(Replace&lt;some_password&gt;\u00a0with a real password!)<\/p>\n<p>mysql&gt;FLUSH PRIVILEGES;<\/p>\n<p>&nbsp;<\/p>\n<p>Next (still on the MySQL shell) do this:<\/p>\n<p>mysql&gt;USE exampledb;<\/p>\n<p>mysql&gt;FLUSH TABLES WITH READ LOCK;<\/p>\n<p>mysql&gt;SHOW MASTER STATUS;<\/p>\n<p>&nbsp;<\/p>\n<p>The last command will show something like this:<\/p>\n<p>+\u2014\u2014\u2014\u2014\u2014+\u2014\u2014\u2014-+\u2014\u2014\u2014\u2014\u2013+\u2014\u2014\u2014\u2014\u2014\u2014+<\/p>\n<p>| File\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0| Position | Binlog_do_db | Binlog_ignore_db |<\/p>\n<p>+\u2014\u2014\u2014\u2014\u2014+\u2014\u2014\u2014-+\u2014\u2014\u2014\u2014\u2013+\u2014\u2014\u2014\u2014\u2014\u2014+<\/p>\n<p>| mysql-bin.006 | 183\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0| exampledb\u00a0\u00a0\u00a0\u00a0|\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0|<\/p>\n<p>+\u2014\u2014\u2014\u2014\u2014+\u2014\u2014\u2014-+\u2014\u2014\u2014\u2014\u2013+\u2014\u2014\u2014\u2014\u2014\u2014+<\/p>\n<p>1 row in set (0.00 sec)<\/p>\n<p>&nbsp;<\/p>\n<p>Write down this information, we will need it later on the slave!<\/p>\n<p>Then leave the MySQL shell:<\/p>\n<p>&nbsp;<\/p>\n<p>mysql&gt;quit;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Step 2 \u2013 Configure the Slave Server(Windows XP)<\/strong><\/p>\n<p><strong><br \/>\n<\/strong><\/p>\n<p>Edit the\u00a0c:\\program files\\mysql\\mysql server 5.0\\my.ini<\/p>\n<p>server-id=2<\/p>\n<p>master-host=db01.yourdomain.net (or IP address)<br \/>\nmaster-port=3306<br \/>\nmaster-user=slave_user<br \/>\nmaster-password=password<\/p>\n<p><strong>Step 3 \u2013 Restart Mysql Service\u00a0<\/strong><\/p>\n<p>goto&gt; Control Panel&gt;Administrative Tools&gt;Services&gt;Mysql<\/p>\n<p>Restart Service<\/p>\n<p>mysql &gt; Stop slave;<\/p>\n<p>mysql&gt;CHANGE MASTER TO MASTER_HOST=\u2019192.168.10.175?, MASTER_USER=\u2019slave_user\u2019, MASTER_PASSWORD=\u2019password\u2019,MASTER_LOG_FILE=\u2019mysql-bin.000008?,MASTER_LOG_POS=98;<\/p>\n<p>mysql &gt; Start slave;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Step 1 \u2013 Configure the Master Server<\/p>\n<p>First we have to edit \/etc\/mysql\/my.cnf. We have to enable networking for MySQL, and MySQL should listen on all IP addresses, therefore we comment out these lines (if existant):<\/p>\n<p>#skip-networking<\/p>\n<p>#bind-address = 127.0.0.1<\/p>\n<p>Furthermore we have to tell MySQL for which database it should write logs (these logs [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/2179"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2179"}],"version-history":[{"count":2,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/2179\/revisions"}],"predecessor-version":[{"id":2181,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/2179\/revisions\/2181"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2179"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2179"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2179"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}