Resolving Error: master and slave have equal MySQL server UUIDs

If you’ve run into the following error, then there area couple quick fixes:

Errno: 1593
Fatal error: The slave I/O thread stops because master and slave
have equal MySQL server UUIDs; these UUIDs must be different for
replication to work.

To give some background first, starting in MySQL 5.6, the server generates a true UUID in addition to the –server-id supplied by the user. This is ultimately to help with new replication features.

From a under-the-hood view, when starting, the MySQL server automatically obtains a UUID as follows (per the manual):

  1. Attempt to read and use the UUID written in the file data_dir/auto.cnf (where data_dir is the server’s data directory); exit on success.
  2. Otherwise, generate a new UUID and save it to this file, creating the file if necessary.

First, this means there is a new file (in 5.6+) located in the datadir named auto.cnf. In this file is a unique uuid for the server.

This is great, but if you are unaware of it, and simply copy the datadir to set up a slave, and do not remove this file, then you’re in for some errors. So just be cautious/aware of this. Some of these errors are easier to track down, such as in this case, a master and slave with the same uuid throws an error right away in the SHOW SLAVE STATUS and the error log. However, if your master is different from the slave, but you have 2 slaves with the same uuid, you’re in for trouble, and the errors are not very descriptive. [More on this soon, once I can test it a bit more, but I saw some strange behaviors in my first tests.]

So, to fix it, simply delete the auto.cnf file, and restart that instance. A new auto.cnf file / and uuid will be generated. For reference, you’d see something like the following in your error log:

2013-05-20 23:02:54 14552 [Warning] No existing UUID has been found, so we
assume that this is the first time that this server has been started.
Generating a new UUID: ee603f24-c1c2-11e2-ad03-089e01009f6a.

The other way is to generate a new UUID (SELECT UUID(); from any MySQL/MariaDB command line) and replace it with the old one in the auto.cnf file.

In either case, you must restart mysqld after the delete or edit for the change to the uuid to take effect.

After that, you’ll be good to go.

For reference, here is the SHOW SLAVE STATUS output:

mysql> show slave status\G
*************************** 1. row ***************************
...
                Last_IO_Errno: 1593
                Last_IO_Error: Fatal error: The slave I/O thread stops because
                               master and slave have equal MySQL server UUIDs;
                               these UUIDs must be different for replication to work.
...

And here is the error logged to the error log:

[ERROR] Slave I/O: Fatal error: The slave I/O thread stops because master
and slave have equal MySQL server UUIDs; these UUIDs must be different for
replication to work. Error_code: 1593