標籤:.com root replica star lin status class window index
同一台電腦配置mysql5.5兩個執行個體,分別在3310和3311兩個連接埠。設定3310為主庫,3311為從庫。
最終效果如下:
3310主庫:
grant replication slave,reload,super on *.* to slave@192.168.1.110 identified by ‘123456‘;
-- my.ini檔案中的[mysqld]下增加server-id = 1replicate-do-db=test1
3311從庫:
-- my.ini檔案中的[mysqld]增加server-id = 2replicate-do-db=test1relay-log=relay-binrelay-log-index=relay-bin-index
stop slave;
-- 【方法一】
change master to master_host=‘192.168.1.110‘,master_port=3310,master_user=‘slave‘,master_password=‘123456‘;-- 【方法二】若指定position同步,請使用(後面兩個參數通過主庫命令“show master status;”查看):
change master to master_host=‘192.168.1.110‘,master_port=3310,master_user=‘slave‘,master_password=‘123456‘,
master_log_file=‘mysql-bin.000001‘,master_log_pos=107;
start slave;
至此,配置完畢,通過命令:
show slave status\G;
查看同步是否串連成功,關鍵計量為:
Slave_IO_Running: YesSlave_SQL_Running: Yes
備忘:
-- 查看server_id:show VARIABLES like ‘server_id‘;
-- 主伺服器上查看主機狀態,File和Positionshow master status;
預設配置的mysql中root賬戶無密碼,通過如下方式修改:
mysql -u root -penter password:(此處直接斷行符號)
-- 修改密碼為123456set password=password(‘123456‘);-- 重新整理許可權flush privileges;
附my.ini設定檔下載:
my.ini下載
參考:
https://www.cnblogs.com/puchengjie/p/5220676.html
主從同步故障解決方案:
Slave_SQL_Running: No
http://blog.51cto.com/kerry/277414
http://blog.chinaunix.net/uid-21505614-id-289477.html
linux下配置主從參考:
http://blog.chinaunix.net/uid-21505614-id-289477.html
window環境下mysql實現主從同步