Question :
Running mysql in a two master replication setup. There are many databases and they are all replicating correctly including the mysql database itself.
Is it safe to replicate mysql or should I exclude it via the my.cnf ?
Answer :
Since the mysql
schema is usually manipulated with GRANT and REVOKE commands, there is no need to let the mysql
schema replicate. Why ?
Someone could hack privileges in by means of INSERT commands into mysql.user
.
Such hacks are possible because I wrote about it before
Oct 28, 2011
: MySQL: trying to create root userSep 12, 2011
: How do you gain access to embedded MySQL database via localhost command line?Mar 06, 2011
: Installing default MySQL Tables in Windows (mysql_install_db)
If these hacks were done on a Master, a Slave might intercept them. The new grants on the Slave would not be active until someone restarted mysqld on the Slave or ran FLUSH PRIVILEGES;
on the Slave.
So, to answer your question: exclude it via the my.cnf