2

I want to change the MySQL DB password on the master db. My question is: do we have to care for the slave DB when changing the master database password?

2
  • What's password do you mean? root password? Or password used by mysql-slave?
    – masegaloeh
    Jun 4, 2014 at 7:46
  • The password used to connect to the master db. Jun 4, 2014 at 7:51

3 Answers 3

2

From the docs

User privileges are replicated only if the mysql database is replicated. That is, the GRANT, REVOKE, SET PASSWORD, CREATE USER, and DROP USER statements take effect on the slave only if the replication setup includes the mysql database.

If you are replicating all databases, but do not want statements that affect user privileges to be replicated, set up the slave not to replicate the mysql database, using the --replicate-wild-ignore-table=mysql.% option. The slave recognizes that privilege-related SQL statements have no effect, and thus it does not execute those statements.

See Section 16.4.1.16, “Replication of the mysql System Database”, for more information.

2
  • Thank you @mvillar, and how to know if this is the case (replicating all the databases) ? Jun 4, 2014 at 9:17
  • in my.conf, the binlog-do-db and binlog-ignore-db are what you're looking for.
    – mvillar
    Jun 4, 2014 at 10:01
2

it really DEPENDS. :)

according to the doc

MySQL 5.1.14 and later. Data modification statements made to tables in the mysql database are replicated according to the value of binlog_format; if this value is MIXED, these statement are replicated using the row-based format. However, statements that would normally update this information indirectly—such GRANT, REVOKE, and statements manipulating triggers, stored routines, and views—are replicated to slaves using statement-based replication.

MySQL 5.1.13 and earlier. User privileges are replicated only if the mysql database is replicated. That is, the GRANT, REVOKE, SET PASSWORD, CREATE USER, and DROP USER statements take effect on the slave only if the replication setup includes the mysql database.

for our instance, mysql 5.5 will automatically CREATE / DROP USER xxx@'xxx' on the slave even we are not doing replication of the mysql system database.

1
  • This. I just experienced this on MySQL 5.5 when setting up replication for the first time. Connecting to the master failed because the replication user's password was too long (yay, maximum length is 32) and when I changed that and started the slave again, it crashed because the replication user couldn't be found in the slave. (As it shouldn't be, because it's used only to do the replication in the master's end.)
    – MJV
    Nov 30, 2016 at 19:40
1

it depends whether or not you are slaving the "mysql" database, the internal mysql db where all user permissions are kept. if the replication user has been given access to "*.*", then all the tables in "mysql.*" should replicate over, including "mysql.user", where passwords are stored.

when changes to this tables are made, a "flush privileges" should be executed, so it may be necessary to run this on the slaves? i always specify specific db's for replication, so i have not tested this.

1
  • Thank you nandoP, and how to be sure that the replication user has been given access to "."? Jun 4, 2014 at 9:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .