# Example MySQL config file for medium systems.

#

# This is for a system with little memory (32M - 64M) where MySQL plays

# an important part, or systems up to 128M where MySQL is used together with

# other programs (such as a web server)

#

# You can copy this file to

# /etc/my.cnf to set global options,

# mysql-data-dir/my.cnf to set server-specific options (in this

# installation this directory is C:\mysql\data) or

# ~/.my.cnf to set user-specific options.

#

# In this file, you can use all long options that a program supports.

# If you want to know which options a program supports, run the program

# with the "--help" option.





# The following options will be passed to all MySQL clients

[client]

#password = your_password

port = 3306

socket = /tmp/mysql.sock





# Here follows entries for some specific programs





# The MySQL server

[wampmysqld]

port = 3306

socket = /tmp/mysql.sock

key_buffer_size = 16M

max_allowed_packet = 1M

sort_buffer_size = 512K

net_buffer_length = 8K

read_buffer_size = 256K

read_rnd_buffer_size = 512K

myisam_sort_buffer_size = 8M

basedir=D:/wamp/bin/mysql/mysql5.6.17

log-error=D:/wamp/logs/mysql.log

datadir=D:/wamp/bin/mysql/mysql5.6.17/data





lc-messages-dir=D:/wamp/bin/mysql/mysql5.6.17/share





# Change your locale here !

lc-messages=fr_FR





# Avoid warning

explicit_defaults_for_timestamp = TRUE





# Don't listen on a TCP/IP port at all. This can be a security enhancement,

# if all processes that need to connect to mysqld run on the same host.

# All interaction with mysqld must be made via Unix sockets or named pipes.

# Note that using this option without enabling named pipes on Windows

# (via the "enable-named-pipe" option) will render mysqld useless!

# 

#skip-networking





# Disable Federated by default

skip-federated





# Replication Master Server (default)

# binary logging is required for replication









# binary logging format - mixed recommended

#binlog_format=mixed





# required unique id between 1 and 2^32 - 1

# defaults to 1 if master-host is not set

# but will not function as a master if omitted

server-id = 1

log-bin=D:/wamp/bin/mysql/mysql5.6.17/mysqlback

binlog-do-db = backup_db

replicate-do-db = backup_db

skip-slave-start=0

# Replication Slave (comment out master section to use this)





# New for MySQL 5.6 if no slave









#

# To configure this host as a replication slave, you can choose between

# two methods :

#

# 1) Use the CHANGE MASTER TO command (fully described in our manual) -

#    the syntax is:

#

#    CHANGE MASTER TO MASTER_HOST=<host>, MASTER_PORT=<port>,

#    MASTER_USER=<user>, MASTER_PASSWORD=<password> ;

#

#    where you replace <host>, <user>, <password> by quoted strings and

#    <port> by the master's port number (3306 by default).

#

#    Example:

#

#    CHANGE MASTER TO MASTER_HOST='125.564.12.1', MASTER_PORT=3306,

#    MASTER_USER='joe', MASTER_PASSWORD='secret';

#

# OR

#

# 2) Set the variables below. However, in case you choose this method, then

#    start replication for the first time (even unsuccessfully, for example

#    if you mistyped the password in master-password and the slave fails to

#    connect), the slave will create a master.info file, and any later

#    change in this file to the variables' values below will be ignored and

#    overridden by the content of the master.info file, unless you shutdown

#    the slave server, delete master.info and restart the slaver server.

#    For that reason, you may want to leave the lines below untouched

#    (commented) and instead use CHANGE MASTER TO (see above)

#

# required unique id between 2 and 2^32 - 1

# (and different from the master)

# defaults to 2 if master-host is set

# but will not function as a slave if omitted

#server-id       = 2

#

# The replication master for this slave - required

#master-host     =   <hostname>

#

# The username the slave will use for authentication when connecting

# to the master - required

#master-user     =   <username>

#

# The password the slave will authenticate with when connecting to

# the master - required

#master-password =   <password>

#

# The port the master is listening on.

# optional - defaults to 3306

#master-port     =  <port>

#

# binary logging - not required for slaves, but recommended

#log-bin=mysql-bin





# Point the following paths to different dedicated disks

#tmpdir = /tmp/


#log-update = /path-to-dedicated-directory/hostname





# Uncomment the following if you are using InnoDB tables

#innodb_data_home_dir = C:\mysql\data/

#innodb_data_file_path = ibdata1:10M:autoextend

#innodb_log_group_home_dir = C:\mysql\data/

#innodb_log_arch_dir = C:\mysql\data/

# You can set .._buffer_pool_size up to 50 - 80 %

# of RAM but beware of setting memory usage too high

#innodb_buffer_pool_size = 16M

#innodb_additional_mem_pool_size = 2M

# Set .._log_file_size to 25 % of buffer pool size

#innodb_log_file_size = 5M

#innodb_log_buffer_size = 8M

#innodb_flush_log_at_trx_commit = 1

#innodb_lock_wait_timeout = 50





[mysqldump]

quick

max_allowed_packet = 16M





[mysql]

no-auto-rehash

# Remove the next comment character if you are not familiar with SQL

#safe-updates





[isamchk]

key_buffer = 20M

sort_buffer_size = 20M

read_buffer = 2M

write_buffer = 2M





[myisamchk]

key_buffer = 20M

sort_buffer_size = 20M

read_buffer = 2M

write_buffer = 2M





[mysqlhotcopy]

interactive-timeout





[mysqld]

port=3306

explicit_defaults_for_timestamp = TRUE

上面是我的配置文件

配置方法如下:

server-id = 1  #每台机器不一样就行了

log-bin=D:/wamp/bin/mysql/mysql5.6.17/mysqlback #通过日志同步,所以这个目录要建一下

binlog-do-db = backup_db                                         #同步数据库 多个就写多行

replicate-do-db = backup_db                                     #同步数据库 多个就写多行

skip-slave-start=0                                                      #启动后自动启动slave模式

在mater上添加用户(如果互为主从都需要设置)

grant file,select,replication slave on *.* to 'cw'@'192.168.1.%' identified by '111111';

show master status;









在slave上执行配置(如果互为主从都需要设置)

stop slave;

CHANGE MASTER TO MASTER_HOST='192.168.1.150', MASTER_PORT=3306,MASTER_USER='cw', MASTER_PASSWORD='111111';

start slave;

MySql互为主从配置文件及配置方法的更多相关文章

  1. Keepalived与MySQL互为主从自动切换配置

    为解决Mysql数据库单点问题,实现两台MySQL数据库互为主备,双向replication.当一Master出现问题,则将Slave切换为Master继续工作. 环境说明 系统版本:CentOS L ...

  2. MySQL数据库主从分离的配置方法

    1.介绍 MySQL数据库设置读写分离,可以使对数据库的写操作和读操作在不同服务器上执行,提高并发量和响应速度.现在的网站一般大点的,都采用有数据库主从分离.读写分离,既起到备份作用也可以减轻数据库的 ...

  3. mysql互为主从(双主)配置

    环境: ubuntu18.04.2 mysql5.7.21 #创建mysql属组 groupadd mysql useradd -g mysql mysql #查看属组 tail /etc/passw ...

  4. mysql互为主从实战设置详解及自动化备份(Centos7.2)

    mysql互为主从实战设置详解(Centos7.2) 第一步:mysql配置  my.cnf配置 服务器1 (10.89.10.90) [mysqld]  server-id=1  log-bin=/ ...

  5. shell 环境变量的相关配置文件和配置方法

    shell 环境变量的相关配置文件和配置方法: bash 的配置文件: 全局配置: /etc/profile, /etc/profile.d/*.sh, /etc/bashrc 个人配置 ~/.bas ...

  6. mysql 5.7.13 安装配置方法图文教程(win10) (转)

    http://www.jb51.net/article/87152.htm ***************************** MySQL是一款关系型数据库管理系统,是由Oracle旗下公司M ...

  7. mysql 5.7.15 安装配置方法图文教程(转)

    http://www.jb51.net/article/92521.htm ******************************* MySQL数据库作为关系型数据库中的佼佼者,因其体积小,速度 ...

  8. mysql 5.7.14 安装配置方法图文教程(转)

    http://www.jb51.net/article/90259.htm ******************************** 因笔者个人需要需要在本机安装Mysql,先将安装过程记录如 ...

  9. mysql 5.7.13 安装配置方法(linux)-后期部分运维

    mysql 5.7.13 安装配置方法图文教程(linux) 学习了:https://www.cnblogs.com/zhao1949/p/5947938.html /usr/local/mysql是 ...

随机推荐

  1. 使用js/jquery查找iframe中的

    原生js  一.在iframe的父窗口中获取iframe中的元素: js代码 格式: window.frames["iframe的name值"].document.getEleme ...

  2. pycharm控制台出现python编译器的编辑功能

    一.最近研究了下python,然后昨天发现新建项目后,出现如图的输入状况(Ctrl+Alt+F10) 二 二.更改方式 (1)点开如图位置,进入编辑模式 (2)将如图位置的√去掉就好了

  3. java并发编程实战:第二章----线程安全性

    一个对象是否需要是线程安全的取决于它是否被多个线程访问. 当多个线程访问同一个可变状态量时如果没有使用正确的同步规则,就有可能出错.解决办法: 不在线程之间共享该变量 将状态变量修改为不可变的 在访问 ...

  4. Computer

    Computer 1. Ctrl+N .根据惯例,“Control”.“Shift” 以及 “Alternate” 按键将以 Ctrl.Shift 以及 Alt 来表示,需要特别指出的是,其中第一个按 ...

  5. 试题 F: 特别数的和 第十届蓝桥杯

    试题 F: 特别数的和时间限制: 1.0s 内存限制: 512.0MB 本题总分: 15 分[问题描述]小明对数位中含有 2. 0. 1. 9 的数字很感兴趣(不包括前导 0),在 1 到40 中这样 ...

  6. Sourcetree拉取推送问题

    以下sourcetree使用时出现的问题:可以暂时用删除passwd文件解决 拉取时账号密码输入错误 已经有一个远程仓库了,但是需要拉取另一个远程仓库时,提示URL 进入 C:\Users\用户名\A ...

  7. centos 7.6 开机报错信息(一):welcome to emergency mode!

    welcome to emergency mode!after logging in ,type "journalctl -xb" to view system logs,&quo ...

  8. Blend 2015 教程 (五) 自定义状态

    本篇再补充一块内容,就是自定义状态的介绍. 自定义状态用于封装用户控件在各种状态之间切换时的外观变化及其动画效果,方便调用.比如有个用户控件用于实现类似舞台幕布打开和关闭切换的效果,可以创建幕布关闭和 ...

  9. Postgresql 用户管理

    一, 设置超级用户密码 1  修改 pg_hba.conf 使超级用户postgres 可以登录到数据库中 host all all 127.0.0.1/32 trust 2 修改 postgres ...

  10. HTML5使用总结(一)

    自己在“上海某985大学”待了五年,有蛮多的不舍.但是终究还是要离开.下面对这几年HTML5的使用做一个总结.总结是一种技术的沉淀.HTML5大家现在很火,它的标准已经出来.在标准还没有成型的时候,相 ...