更改my.cnf以设置MySQL复制

时间:2019-05-15 08:12:29

标签: mysql ubuntu

我正在按照this教程来设置MySQL复制(我正在使用Ubuntu)。

根据以上教程,这是我想要的my.cnf文件中的配置:

[mysqld]
log-bin = mysql-bin
server-id = 1
relay-log = relay-log-slave
gtid-mode =ON
enforce-gtid-consistency
binlog_format = MIXED
log_slave_updates

我在以下位置找到了my.cnf:/etc/mysql

enter image description here

当我打开my.cnf时,这就是内容(不确定为什么文件图标看起来像快捷图标吗?):

#
# The MySQL database server configuration file.
#                                              /****************************/
# You can copy this to one of:                 /* <-- what does this mean? */   
# - "/etc/mysql/my.cnf" to set global options, /****************************/    
# - "~/.my.cnf" to set user-specific options.
# 
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

#
# * IMPORTANT: Additional settings that can override those from this file!
#   The files must end with '.cnf', otherwise they'll be ignored.
#

!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/

我希望在my.cnf中找到诸如log-binserver-idgtid-mode之类的设置。我以为我应该更改设置值。我不确定这是否是正确的文件,因为此处没有这些设置值...

文件顶部的注释还告诉我可以将其复制到/etc/mysql/my.cnf,但这是我从中打开文件的地方!我对此评论感到困惑...

这是正确的文件吗?我应该自己添加所有设置吗?


更新

/etc/mysql/mysql.conf.d/mysqlid.cnf中似乎所有设置都存在,我是否应该更改此文件?

1 个答案:

答案 0 :(得分:1)

从MySQL 5.7开始,默认配置文件路径为/etc/mysql/mysql.conf.d/mysqld.cnf

5.7之前的文件路径将为/etc/mysql/my.cnf/etc/my.cnf

如果该参数不存在,则添加配置文件的[mysqld]部分。