Home > Database > Mysql Tutorial > mysql复制功能“master-slave”结构_MySQL

mysql复制功能“master-slave”结构_MySQL

WBOY
Release: 2016-06-01 13:34:27
Original
1134 people have browsed it

bitsCN.com

一、配置主服务器

  1.my.ini中添加内容

  

  2.创建“复制权限”的账号

      创建账号

   

   

         给创建的账号授予“待复制数据库”上所有的操作权限

   

         查看所有用户

SELECT DISTINCT CONCAT('User: ''',user,'''@''',host,''';') AS query FROM mysql.user;
Copy after login

   

   查看用户权限

   

  3.重启mysql服务

二、配置从服务器

  1.my.ini中添加内容

    

   注:从库my.ini的配置中,Mysql5.5版本以上不再支持master的用法,比如5.1

    中可用的(master-user = repl;master-password = repl;master-port = 3307),

    如果在mysql5.5版本以上中使用该语法会导致,mysql服务无法启动。

  2.重启mysql服务器

    3.开启从库复制功能

       a)关闭从库复制功能

stop slave;
Copy after login

  

   b)设置主库连接串

change master to  master_host="10.0.0.10",  master_port=3306,  master_user="slave1",  master_password="feng" ;
Copy after login

  

      注:出现警告是没关系的,只是密码是明文等提示。

            此处还可指明“主库”二进制文件名和位置

    eg:

      查看主库信息可用以下命令完成:

     

   c)打开从库复制功能

start slave;
Copy after login

   

   d)查看从库状态

   

三、测试

      1.连接到主库上,插入一行数据

  

  

  2.在从库上执行查询

  

  mysql复制功能“master-slave”结构_MySQL

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template