Friday, 23 March 2012

MySql Replication - Error 1045

Fighting with a simple test-bed MySql replication between 2 Ubuntu 10.04 LTS servers.

It turned out you need to use the domain name, not the IP address when specifying the MASTER_HOST in the following MySql command on the Slave:

CHANGE MASTER TO MASTER_HOST='192.168.0.100', MASTER_USER='[username]', MASTER_PASSWORD='[password]', MASTER_LOG_FILE='mysql-bin.NNNNNN', MASTER_LOG_POS=N;



I set it all up according to the information I found on this simple and useful article on howtoforge. All seemed configured correctly, but I was seeing an error on the slave in mysql:

mysql> show slave status \G
*************************** 1. row ***************************
Slave_IO_State: Connecting to master
Master_Host: [master IP address]
Master_User: [username]
Master_Port: 3306
Connect_Retry: 60
...
Slave_IO_Running: No
Slave_SQL_Running: Yes
...
Last_IO_Errno: 1045
Last_IO_Error: error connecting to master '[username]@[master IP address]:3306' retry-time: 60 retries: 86400
Last_SQL_Errno: 0
Last_SQL_Error:




In the /var/log/mysql/error.log I could see:

120323 9:04:46 [ERROR] Slave I/O: error connecting to master '[username]@[master IP address]:3306' - retry-time: 60 retries: 86400, Error_code: 1045


Eventually I spotted this little nugget hidden away:

Turns out that for some odd reason it won't work when I specify
master_host as an IP-address, but it WILL work when I put the hostname
in.

That solved it!

No comments:

Post a Comment