Mysql – Cannot connect to thesql server error for master replication

MySQLreplication

Am trying to connect to a mysql master which is a server running LAMP. It replies with an error "cannot connect to mysql server". Have also tried to connect using mysql -h XXX -u -p from the slave server but still replies the same error. On the LAMP server have also checked the iptables and allowed mysql port to allow incoming connection but still have the same error. Have also allowed my slave public ip but the error is just the same.

Best Answer

Using this mysql -h XXX -u -p you cannot connect to mysql remotely using root, if you want to connect with root remotely you have to configure it. For replication you need to create replication user on master and give it replication priviliges.

example;

mysql> CREATE USER 'repl'@'%.example.com' IDENTIFIED BY 'password';

mysql> GRANT REPLICATION SLAVE ON . TO 'repl'@'%.example.com';

start your slave and check what is the error on IO thread also check slave log for any errors.