How to Setup MySQL (Master-Slave) Replication in RHEL, CentOS, Fedora

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Use our Linode referral link if you plan to buy VPS (it starts at only $10/month).
  4. Support us via PayPal donate - Make a Donation
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

We are thankful for your never ending support.

Ravi Saive

I am Ravi Saive, creator of TecMint. A Computer Geek and Linux Guru who loves to share tricks and tips on Internet. Most Of My Servers runs on Open Source Platform called Linux. Follow Me: Twitter, Facebook and Google+

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

Receive Your Free Complimentary eBook NOW! -

Download Free Linux eBooks

Linux BASH Programming Cookbook
Getting Started with Ubuntu 16.04
A Newbie's Getting Started Guide to Linux
Introduction to Linux - A Hands on Guide

You may also like...

141 Responses

  1. Gulshan Upadhyay says:

    Failed to import dbdump file on slave side….

    Getting error while running the command….

    # mysql -u root -p < /root/dbdump.db (On the slave node)

    ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

    I have same os on both machine (i.e. Rhel7)

    Plz.. give complete solution

    • Ravi Saive says:


      Please make sure that MySQL started and running, if not you can start it using:

      # service mysqld restart
      # systemctl restart mysqld
  2. Rusdi says:

    Thankyou so much pals for this superb great tutorial. It really helpful.

  3. Tapas Sen says:


    Getting error while running the command….

    # mysql -u root -p < dbstore.db (On the slave node)

    ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

  4. Muhammad Shidiq says:

    I’ve two VM located on Digital Ocean and Microsoft Azure, I use my Digital Ocean as master and Microsoft Azure as slave. Can I implement replication in different server like Digital Ocean and Azure?

    • Ravi Saive says:


      Not possible, both servers must be same Linux OS to do database Master/Slave replication…

      • Muhammad Shidiq says:

        Hi Ravi,

        I mean same OS (linux) but different server. I’ve ubuntu in DO and Azure, so can I do master-slave replication?

        • Ravi Saive says:


          As fas as both machine with different Linux OS will work without any issues, yes you can do a master-slave MySQL replication without any doubt…:)

  5. yogesh says:

    thanks for reply..can u please make tutorial on or write blog for how to use replication for wamp server one slave and multiple masters.Thanks.

  6. Yogesh says:

    nice post..I am using master on windows,and my server is on cent-OS..whenever I try to run CHANGE MASTER TO…. this gives me error like slave is not configured or server_id is not set on master or slave…Thanks

    • Yogesh says:

      I am doing this with WAMP3 Server.

      • Ravi Saive says:


        If am not wrong WAMP means Windows, Apache, MySQL and PHP? if yes, then how come these commands work on Windows? better have a Linux..

    • Ravi Saive says:


      I don’t think it will work that way, both machines must be Linux OS.

      • Yogesh says:

        Slave is not configured or failed to initialize properly. You must at least set –server-id to enable either a master or a slave.
        now I am getting this error..1st time its work after second time when I try to look out through START SLAVE…STOP SLAVE its produced this error..can u explain why?

        | Variable_name | Value |
        | server_id | 11 |

        my.cnf file has
        server_id = 11
        replicate_do_db = dbname

        • yogesh says:

          pls reply I stuck on this error…

          • Ravi Saive says:


            Sorry, as I said it’s difficult to answer you question, as you’re using two different OS’s for same purpose, and I don’t think it work that way, both machine must be Linux operating systems, in order to work properly…..

  7. Ahmet Mert ALPAT says:

    Great Article. Works Fine.. Thanks so much. Appreciate !

  8. Amit says:

    Awesome!!!! Really thanks for the post,, and its working perfectly

Got something to say? Join the discussion.

Your email address will not be published. Required fields are marked *

Join Over 300K+ Linux Users
  1. 177,942
  2. 8,310
  3. 37,548

Are you subscribed?