Documentation Home
MySQL 5.5 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 26.9Mb
PDF (A4) - 26.9Mb
PDF (RPM) - 25.3Mb
HTML Download (TGZ) - 6.3Mb
HTML Download (Zip) - 6.3Mb
HTML Download (RPM) - 5.3Mb
Man Pages (TGZ) - 158.7Kb
Man Pages (Zip) - 262.0Kb
Info (Gzip) - 2.6Mb
Info (Zip) - 2.6Mb
Excerpts from this Manual

MySQL 5.5 Reference Manual  /  ...  /  Creating a User for Replication Creating a User for Replication

Each slave must connect to the master using a 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 may wish to create a different account for each slave, or connect to the master using the same account for each slave.

You need not create an account specifically for replication. However, you should be aware that the user name and password will be stored in plain text within the file (see Section, “Slave Status Logs”). Therefore, you may want to create a separate account that has privileges only for the replication process, to minimize the possibility of compromise to other accounts.

To create a new account, use CREATE USER. To grant this account the privileges required for replication, use the GRANT statement. If you create an account solely for the purposes of replication, that account needs only the REPLICATION SLAVE privilege. For example, to set up a new user, repl, that can connect for replication from any host within the domain, issue these statements on the master:

mysql> CREATE USER 'repl'@'' IDENTIFIED BY 'password';
mysql> GRANT REPLICATION SLAVE ON *.* TO 'repl'@'';

See Section 13.7.1, “Account Management Statements”, for more information on statements for manipulation of user accounts.

User Comments
  Posted by Thomas Zenz on October 6, 2008
-> TO 'repl'@'' IDENTIFIED BY 'slavepass';

I had to use only the hostname of the slave.
  Posted by John Dixon on January 28, 2009
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 replicant

It will resolve differently than replicant

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.
Sign Up Login You must be logged in to post a comment.