Search code examples
mysqlpasswordsreplication

How do I update mysql replicant users new password into slave master. info file


need a quick help. We have a user called replicant which we use as replication user. Due to security, I had to change replicant user's password.

I changed password on master mysql server and slave status shows fine. I know we replicate mysql database itself.

Now, on slave master.info still showing old password, I know it keeps binlog position and I shouldn't be editing it. Now what to do? How to update since slave starts using this file. 😕😕 help.


Solution

  • Yeah, don't edit the master.info file directly. The best way to update it is to use the CHANGE MASTER statement.

    You can use the MySQL client and run these statements on the replica instance:

    STOP SLAVE;
    CHANGE MASTER TO MASTER_PASSWORD='...';
    START SLAVE;
    

    That CHANGE MASTER statement also allows you to change several other options. You can change a subset of them, or even just one, e.g. the password.

    On MySQL 8.0.23 and later, use STOP REPLICA and START REPLICA and CHANGE REPLICATION SOURCE TO ... instead.