10bet网址
MySQL 8.0 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr)- 41.6Mb
PDF (A4)- 41.7Mb
Man Pages (TGZ)- 262.2Kb
Man Pages (Zip)- 372.3Kb
Info (Gzip)- 4.0Mb
Info (Zip)- 4.0Mb
Excerpts from this Manual

17.1.2.3 Creating a User for Replication

Each replica connects to the source using a MySQL user name and password, so there must be a user account on the source that the replica can use to connect. The user name is specified by theSOURCE_USER|MASTER_USERoption of theCHANGE REPLICATION SOURCE TOstatement (from MySQL 8.0.23) orCHANGE MASTER TOstatement (before MySQL 8.0.23) when you set up a replica. Any account can be used for this operation, providing it has been granted theREPLICATION SLAVEprivilege. You can choose to create a different account for each replica, or connect to the source using the same account for each replica.

Although you do not have to create an account specifically for replication, you should be aware that the replication user name and password are stored in plain text in the replica's connection metadata repositorymysql.slave_master_info(seeSection 17.2.4.2, “Replication Metadata Repositories”). 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, useCREATE USER. To grant this account the privileges required for replication, use theGRANTstatement. If you create an account solely for the purposes of replication, that account needs only theREPLICATION SLAVEprivilege. For example, to set up a new user,repl, that can connect for replication from any host within theexample.comdomain, issue these statements on the source:

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

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

Important

To connect to the source using a user account that authenticates with thecaching_sha2_passwordplugin, you must either set up a secure connection as described inSection 17.3.1, “Setting Up Replication to Use Encrypted Connections”, or enable the unencrypted connection to support password exchange using an RSA key pair. Thecaching_sha2_passwordauthentication plugin is the default for new users created from MySQL 8.0 (for details, seeSection 6.4.1.2, “Caching SHA-2 Pluggable Authentication”). If the user account that you create or use for replication (as specified by theMASTER_USERoption) uses this authentication plugin, and you are not using a secure connection, you must enable RSA key pair-based password exchange for a successful connection.