MySQL主从复制详细讲解(二)快速实现_MySQL
Jun 01, 2016 pm 01:01 PM
<span style="font-size:18px;">简单步骤总结--快速实现: 一:主服务器的配置步骤: 2:给从服务器设置授权用户 grant all on *.* to user1@192.168.10.2 identified by "pass123"; (all表示所有权限的意思,授权所有的用户,关于数据库所有的表(只能是这台服务器192.168.10.2,如果主机是字符串单引号扩着'leyangjunpc'):账号是user1 密码是pass123) GRANT REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO repl@'192.168.0.%' IDENTIFIED BY 'p4ssword'; 3:修改主数据库服务器的配置文件my.cnf/ini,开启bin-log日志,并设置server-id的值 log-bin=mysql-bin server-id=1 (主从server-id一定要保证唯一,不能相同) --一主多从也一样 二:从服务器的配置步骤: 1:配置文件中:修改数据库的server-id,注意server-id的值必须是唯一的,不能和主数据的配置相同,如果有多个 从服务器,每个从服务器必须有自己唯一的server-id值 开启bin-log 2:Mysql版本从5.1.7以后开始就不支持“master-host”类似的参数 在从库上执行如下命令; change master to master_host='masterIP', master_user='slave', master_password='slvaePASS'; slave start;重启 3:配置完后->检测是否和主服务器同步方法(数据同步成功不成功就看*): show slave status\G 看到:* Salve_IO_Running :Yes (表示成功的把主服务器的bin-log日志拿回来了且同步,写一行我就同步一行) * Salve_SQL_Running :Yes (拿过来的bin-log日志并成功的执行了sql语句,一主数据一致) --看到为yes的说明已经和主服务器取得同步 master_Log_File:mysql-bin.00002 (同步过来的bin-log日志) Read_Master_Log_Pos:106 (位置,show master status主看下就知道) Connect_Retry:60 (每隔60秒回去主服务器同步bin-log日志) 踪迹日志: Relay-Log_File:localhost-relay-bin.00004 (从服务器生成的日志文件,不叫mysql-bin.xxx) 数据同步过来后,我们查询数据就可以去从服务器上查询不用去主服务器,减轻负载 能后你就可以尽情的玩你的主从复制啦,注意别在从服务器上乱删数据哦,要不能主从同步会有问题的,就够你玩的啦 </span>
Copy after login
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

Hot Article
Repo: How To Revive Teammates
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌

Hot tools Tags

Hot Article
Repo: How To Revive Teammates
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Reduce the use of MySQL memory in Docker

How do you alter a table in MySQL using the ALTER TABLE statement?

How to solve the problem of mysql cannot open shared library

What is SQLite? Comprehensive overview

Run MySQl in Linux (with/without podman container with phpmyadmin)

Running multiple MySQL versions on MacOS: A step-by-step guide

What are some popular MySQL GUI tools (e.g., MySQL Workbench, phpMyAdmin)?

How do I secure MySQL against common vulnerabilities (SQL injection, brute-force attacks)?
