I've been trying to get two databases in docker containers to replicate. I've been working off this article: https://www.digitalocean.com/community/tutorials/how-to-set-up-master-slave-replication-in-mysql (and others).

The state I've been able to get to is that the master and slave dbs have loaded cnf files that set the server-ids, and after the DBs are stood up, I am able to run a few commands that should get the DBs to be connected:

MS_STATUS=`docker exec mysql-master sh -c 'export MYSQL_PWD=password; mysql -u root -e "SHOW MASTER STATUS"'`
CURRENT_LOG=`echo $MS_STATUS | awk '{print $6}'`
CURRENT_POS=`echo $MS_STATUS | awk '{print $7}'`


start_slave_cmd='export MYSQL_PWD=password; mysql -u root -e "'



docker exec mysql-slave sh -c "$start_slave_cmd"

This sets the master_log_file and Read_master_log_pos to the same values in both the master and slave dbs.

The error I am getting is:

mysql-slave               | 2018-09-20T20:13:41.547886Z 11 [ERROR] [MY-010584] [Repl] Slave I/O for channel '': error connecting to master 'replication_user@mysql-master:3306' - retry-time: 60  retries: 1, Error_code: MY-002061

I've looked at the documentation, but I don't see any mention of that error code (2061). What am I missing?

I've named the replication user in both database the same... could that be the issue?

  • Its a network problem between docker containers. Try to connect to the master 3306 port from your docker slave container. Are you using docker-compose to start them in the same namespace? Or exposed ports?
    – danblack
    Sep 20, 2018 at 23:04
  • I have a port forwarded to the host in the docker-compose. Is that different from opening internally.
    – Jeff
    Sep 20, 2018 at 23:30
  • @danblack do I need additional login rights beyond replication? I was able to login via mysql -h mysql-master -u replication_user -p
    – Jeff
    Sep 21, 2018 at 16:03
  • a replication user should be able to connect.
    – danblack
    Sep 21, 2018 at 21:04
  • I was able to do that.
    – Jeff
    Sep 21, 2018 at 21:07

5 Answers 5


Also, you just can run


but this solution has a restriction (see the documentation https://dev.mysql.com/doc/refman/8.0/en/caching-sha2-pluggable-authentication.html)

Use of a trusted local copy of the public key enables the client to avoid a round trip in the client/server protocol, and is more secure than requesting the public key from the server. On the other hand, requesting the public key from the server is more convenient (it requires no management of a client-side file) and may be acceptable in secure network environments.

  1. MY-002061 - it`s problem authentication;
  2. When creating a User, you must explicitly specify the authentication plugin sha256_password;
  3. For example: CREATE USER 'slaveuser'@'%' IDENTIFIED WITH sha256_password BY '0000';
  4. Then: GRANT REPLICATION SLAVE ON *.* TO 'slaveuser'@'%';
  5. After that, of course, re-create everything.

This works for me. Try to use your replication user to connect to the Master server. Example. in your Slave node do below,

mysql -h Master_Server_Ip -u replication_user -p

then monitor your slave node after doing above via SHOW SLAVE STATUS command


On the master SHOW GLOBAL VARIABLES LIKE 'caching_sha2_password_public_key_path'. Copy that file to the slave.

On the slave, use the CHANGE MASTER TO statement with the MASTER_PUBLIC_KEY_PATH option to specify the RSA public key file


During creation you can use old mechanism: CREATE USER 'replicationuser'@'%' IDENTIFIED WITH mysql_native_password BY replicpass;

this mysql_native_password will use old method and in case you are using linklocal to connect to slave is enough.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.