Home > Database > Mysql Tutorial > 教你在MySQL 5.0以上版本中配置主从库_MySQL

教你在MySQL 5.0以上版本中配置主从库_MySQL

WBOY
Release: 2016-06-01 14:02:41
Original
1255 people have browsed it

下面直接记录下配置主从库的操作:(本文用的是mysql5.0以上)

1.在主库建立要同步的数据库,建立主库的帐号和修改主库配置

首先连接上数据库

mysql -S /tmp/mysql-3108.sock

创建测试同步的数据库,"create database sinatest;"

然后建立负责同步的用户

grant all on *.* to ali@"%" Identified by "abc111";

然后修改/data2/ali/mysql3308/my.cnf主库的配置,增加

binlog-do-db=sinatest

2.修改从库配置

然后修改/data2/ali/mysql3309/my.cnf从库的配置,增加

master-host=127.0.0.1

master-user=ali

master-password=abc111

master-port=3308

server-id=2

master-connect-retry=60

replicate-do-db=sinatest

log-slave-updates

3.重启mysql

先杀死mysql进程,然后再启动

/usr/local/mysql/bin/mysqld_safe --defaults-file=/data2/ali/mysql3308/my.cnf --user=root &

/usr/local/mysql/bin/mysqld_safe --defaults-file=/data2/ali/mysql3309/my.cnf --user=root &

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