CentOS Mysql 5.1.73 主从配置

----------------------------------------------

1 修改my.cnf

----------------------------------------------


主数据库:

[mysqld]

datadir=/data/mysql

socket=/var/lib/mysql/mysql.sock

user=mysql

 

server-id = 163

log-bin=/home/data/mysql/mysql_bin.log

binlog_format=mixed

 

binlog-ignore-db=mysql

log-slave-updates

sync_binlog=1

replicate-do-db = aishang

replicate-ignore-db = mysql,information_schema

从数据库

[mysqld]

datadir=/data/mysql

socket=/var/lib/mysql/mysql.sock

user=mysql

 

server-id=164

master-host =192.168.1.181#似乎没用,抄的,保留吧,

master-user=mysync

master-pass=q----

master-port =3306

master-connect-retry=60

replicate-do-db =aishang

replicate-ignore-db=mysql

----------------------------------------------

2 service mysqld restart

主从都重启

----------------------------------------------

主数据库检查状态

mysql> show master status;                                                         

+------------------+----------+--------------+------------------+

| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB |

+------------------+----------+--------------+------------------+

| mysql_bin.000001 | 16371666 |              | mysql            |

+------------------+----------+--------------+------------------+

1 row in set (0.00 sec)

----------------------------------------------

3 从数据库

----------------------------------------------

mysql> change master to master_host='192.168.1.181',master_user='mysync',master_password='-------',master_log_file='mysql_bin.000001' ,master_log_pos=16371666;

mysql> start slave;

------------

注意log-bin的配置必须写到[mysqld]下,否则,不起作用,我就被这个坑了。

上一篇:MariaDB:开启日志记录SQL


下一篇:- Fractal(3.4.1)