Home > Database > Mysql Tutorial > Mysql数据库主从复制部署详解

Mysql数据库主从复制部署详解

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 17:41:49
Original
1245 people have browsed it

目的:主从服务器设置的稳健性得以提升,如果主服务器发生故障,可以把本来作为备份的从服务器提升为新的主服务器。在主从服务器上分开处理用户的请求,可获得更

 Mysql数据库主从复制部署详解

 

主从复制配置

  • insert into mysql.user(host,user,password) values("localhost","rep1",password("mysql")); flush privileges; grant replication slave on *.* to rep1@192.168.56.129 identified by 'mysql';mysql> show master status;

     Mysql数据库主从复制部署详解

  • mysqld_safe --user=mysql &mysql -uroot -pmysql> change master to master_host='192.168.56.128',master_user='rep1' ,master_password='mysql',master_log_file='mysql-bin.000004',master_log_pos=477;

    正确执行后再执行

    mysql> start slave;

     Mysql数据库主从复制部署详解

     Mysql数据库主从复制部署详解

     

     

    如果主数据库服务器已经存在用户数据,那么在进行主从复制时,需要做以下处理。

    mysql>flush tables with read lock;mysql>show master status;

     Mysql数据库主从复制部署详解

    mysql>unlock tables;

    从服务器的操作和前面的步骤一样,网站空间,略过。

  • mysql>create database first_tb;mysql>insert into first_tb values (001,'myself');mysql>show databases;

     Mysql数据库主从复制部署详解

    在从库上查看,网站空间,香港虚拟主机,数据库已经完全导入。

     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
    Latest Issues
    MySQL stops process
    From 1970-01-01 08:00:00
    0
    0
    0
    Error when installing mysql on linux
    From 1970-01-01 08:00:00
    0
    0
    0
    phpstudy cannot start mysql?
    From 1970-01-01 08:00:00
    0
    0
    0
    Popular Tutorials
    More>
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template