hacking with MySQL replication

First off, I have to be honest about my biases: I am not a big fan of MySQL. It has a long list of gotchas; in many cases, it violates what I term “the principle of least surprise”. One quick example: what is the difference between this:

$ mysql -h localhost -u root mysql

and

$ mysql -h 127.0.0.1 -u root mysql

?

Answer: The first command will use the local domain socket (mysql.sock) to connect to the database, and the latter will actually open a TCP/IP connection to localhost.

Why this is relevant will become clear in a moment.

Continue reading