Each slave must connect to the master using a standard MySQL
user name and password, so there must be a user account on the
master that the slave can use to connect. Any account can be
used for this operation, providing it has been granted the
REPLICATION SLAVE
privilege.
You do not need to create a specific user for replication.
However, you should be aware that the user name and password
will be stored in plain text within the
master.info
file. Therefore, you may want to
create a user that only has privileges for the replication
process.
To create a user or grant an existing user the privileges
required for replication, use the
GRANT
statement. If you create a
user solely for the purposes of replication then that user needs
only the REPLICATION SLAVE
privilege. For example, to create a user,
repl
, that can connect for replication from
any host within the mydomain.com
domain,
issue this statement on the master:
mysql> GRANT REPLICATION SLAVE ON *.* -> TO 'repl'@'%.mydomain.com' IDENTIFIED BY 'slavepass';
See Section 12.5.1.3, “GRANT
Syntax”, for more information on the
GRANT
statement.
You may wish to create a different user for each slave, or use
the same user for each slave that needs to connect. As long as
each user that you want to use for the replication process has
the REPLICATION SLAVE
privilege
you can create as many users as you require.
User Comments
GRANT REPLICATION SLAVE ON *.*
-> TO 'repl'@'remotehost.mydomain.com' IDENTIFIED BY 'slavepass';
I had to use only the hostname of the slave.
The host that you use for this GRANT statement will vary depending on the reverse lookup of the host you are using for replication. In my case this will be read from my /etc/hosts in the order that hosts are listed. So if you have in your /etc/hosts
192.168.1.3 replicant.example.com replicant
It will resolve differently than
192.168.1.3 replicant replicant.example.com
Also, if you change this after attempting to start replication, you will need to FLUSH HOSTS to get the updated /etc/hosts to affect the host cache in mysql.
Add your own comment.