I am trying to set up a multi master mysql replication on two systems on a network. The two separate database servers are running mysql at localhost, How do I create a replication user for the hosts since they share the same name.
I could do this, but it doesn’t seem like the right thing to do.
CREATE USER 'repl_user1'@'localhost' IDENTIFIED BY 'password1'; // Server1
CREATE USER 'repl_user2'@'localhost' IDENTIFIED BY 'password2'; // Server2
I think something like this should do
CREATE USER 'repl_user1'@'server1.com' IDENTIFIED BY 'password1'; // Server1
CREATE USER 'repl_user2'@'server2.com' IDENTIFIED BY 'password2'; // Server2
but I don’t know how to give the host a name.
Thanks for any help.
You can use IPs, ex:
If you really want to use hostnames (and you don’t already have some set up for your servers using DNS), just add them to your hosts file and reference those. Ex.:
/etc/hosts (server1)
/etc/hosts (server2)
Then set up the users:
That should work so both servers receive connections from their own host and the other as well and map it to the correct users.