I meet with a problem in the process of setting master to slave one-way replicate system. When I change the setting on master machine, it looks fine. But after I change the setting on slave. The following error message shows up when I try to get into mysql on master server.
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
I guess that the problem occurs maybe because I don't change bind address of servers on /etc/mysql/my.cnf
. So I try again and change bind addresses of both servers. Master and slave server seem to be connected for a while since slave server replicated what master server did. But after a while, the error massager ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
shows up again, first on master server, then on slave. I am trying to fix this problem by restarting servers, but failed.
The following is what I have done so far:
arp -a //find ip of master and slave server
get into [mysqld]:
nano /etc/mysql/my.cnf
add:
for [master]
server-id=1
log-bin=mysql-bin
change bind address to ip address;
for [slave]
server-id=2
replicate-wild-do-table=test.% //only replicate data of database named test
change bind address to ip address;
in mysql
for [master]
create user 'repl'@'%' identified by 'slavepassword';
grant replication slave on *.* to 'repl'@'%';
for [slave]
change master to
master_host='master server's ip',
master_user='repl',
master_password='slavepassword',
master_log_file='mysql-bin.000001', // get from show master status
master_log_pos=1358; // get from show master status
start slave;
show slave status\G;
show processlist;
I do restart master server after changing its setting in the process, but since the error message shows up, restarting failed.
Can anyone please help me out? I've googled it but haven't find any solution yet. Any help will be appreciated.