Search code examples
mysqlwordpresssslnginxdatabase-replication

Slave I/O: error connecting to master


I'm following this tutorial for Master-slave-replication for my database replication and this working fine for test servers in which both servers have not ssl installed. But when I trying to do the same with my production server where only master has ssl installed not slave server, I'm getting this error Slave I/O: error connecting to master 'server-ipaddress:3306' - retry-time: 60 retries: 86400, Error_code: 2003. Is this problem of ssl connection or something else.

Also when setting up mysql configuration on master server after taking dump file of database and unlocking tables my mysql server shut down with my website showing this error error establishing database connection after restarting mysql my website working fine again.

My master server is running on nginx server with wordpress installed and I have also checked that 3306 is listening on my master server. Why my slave unable to connect to my master server, any solution?


Solution

  • You can use command below to check the ip address mysql server is listening

    netstat -nlt | grep 3306
    
    sample result:
    
    tcp 0  0  xxx.xxx.xxx.xxx:3306  0.0.0.0:*   LISTEN
    

    If the result showing same result like me then add a replication master user to access the server database.

    If netfilter firewall is enabled (sudo ufw enable) on mysql server machine, do the following to open port 3306 for remote access:

    sudo ufw allow 3306
    

    check status again :

    sudo ufw status
    

    You will see your tcp port for 3306 is open for connection from anywhere. Now you try to connect from slave server you will get the result.