Mysql – Troubleshooting “Can’t connect …” from MySQL slave to master

mariadbmaster-slave-replicationMySQL

Although I can connect from slave to master via a command-line mysql client, my slave can't connect to the master as part of its replication task. SHOW SLAVE STATUS cites a "Permission denied" error:

Last_IO_Error: error connecting to master 'replicant@dbmaster:5000' – retry-time: 60 maximum-retries: 86400 message: Can't connect to MySQL server on 'dbmaster' (13 "Permission denied")

I've checked the user permissions as well as a command-line client connection. What else can I check?

The user has SELECT and REPLICATION SLAVE permissions on the master:

mysql -h dbmaster -P 5000 -u replicant "-p$PASS" --ssl -e 'SHOW GRANTS'
# +--------------------------------------------------------------------------------------------------------------------------------------------------------+
# | Grants for replicant@192.168.187.101                                                                                                                   |
# +--------------------------------------------------------------------------------------------------------------------------------------------------------+
# | GRANT SELECT, REPLICATION SLAVE ON *.* TO `replicant`@`192.168.187.101` IDENTIFIED BY PASSWORD '[HASH-REDACTED]' REQUIRE SSL |
# +--------------------------------------------------------------------------------------------------------------------------------------------------------+

And I've set up the slave to use the same username, password, host, port, ssl:

cat <<-EOF | mysql
STOP SLAVE;
CHANGE MASTER TO MASTER_SSL=1, MASTER_DELAY=259200,
MASTER_HOST='dbmaster', MASTER_PORT=5000,
MASTER_USER='replicant', MASTER_PASSWORD='$PASS',
MASTER_LOG_FILE='mysql-bin.041117', MASTER_LOG_POS=733093730;
START SLAVE;
EOF

The server is running Mariadb 10.3.

Best Answer

cat <<-EOF | mysql Line OK STOP SLAVE; Line OK

CHANGE MASTER 'AnyName4Slave' TO MASTER_HOST = '',MASTER_PORT=3306, MASTER_USER = 'user', MASTER_PASSWORD = 'password' ,MASTER_LOG_FILE='mysql-bin.041117', MASTER_LOG_POS=733093730;

START SLAVE 'AnyName4Slave'; EOF