关于mysql的binlog

1.binlog的开启和关闭
今天安装完mysql8.0.27发现我在my.cnf配置文件里并没有添加bin-log参数,但是在数据库中查看binlog状态却为开启状态,binlog也能正常生成。

mysql> show variables like '%log_bin%';
+---------------------------------+-------------------------------------------+
| Variable_name                   | Value                                     |
+---------------------------------+-------------------------------------------+
| log_bin                         | ON                                        |
| log_bin_basename                | /usr/local/mysql-8.0.27/data/binlog       |
| log_bin_index                   | /usr/local/mysql-8.0.27/data/binlog.index |
| log_bin_trust_function_creators | OFF                                       |
| log_bin_use_v1_row_events       | OFF                                       |
| sql_log_bin                     | ON                                        |
+---------------------------------+-------------------------------------------+
6 rows in set (0.00 sec)

my.cnf里没有配置bin-log参数

[root@hisdg data]# cat /etc/my.cnf
[mysqld]
basedir=/usr/local/mysql-8.0.27
datadir=/usr/local/mysql-8.0.27/data
socket=/usr/local/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd

[mysqld_safe]
#log-error=/var/log/mariadb/mariadb.log
#pid-file=/var/run/mariadb/mariadb.pid

#
# include all files from the config directory
#
!includedir /etc/my.cnf.d

为啥配置文件里没有bin-log配置,binlog是开启的呢?也需是版本问题,5.7是要手动开启的8.0是不是默认就是开启的呢?

8.0官方文档中找到关于binlog的一段话:大意就是二进制日志默认是开启的,系统参数中log-bin默认是on,可以使用skip-log-bin参数停用binlog。
在这里插入图片描述
查看5.7的官方文档对log-bin参数的描述,在5.7加入这个参数到my.cnf参数文件,才能开启binlog。
在这里插入图片描述
2.更改binlog的存放位置
8.0修改my.cnf参数文件中log-bin参数

[root@hisdg mysql-8.0.27]# cat /etc/my.cnf
[mysqld]
basedir=/usr/local/mysql-8.0.27
datadir=/usr/local/mysql-8.0.27/data
socket=/usr/local/mysql.sock
log-bin=/usr/local/mysql-8.0.27/logbin/log
--注意这里最后一个路径log不是文件夹,这个log是binlog的文件名格式,binlog的实际存放目录是/usr/local/mysql-8.0.27/logbin/
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd

[mysqld_safe]
#log-error=/var/log/mariadb/mariadb.log
#pid-file=/var/run/mariadb/mariadb.pid

#
# include all files from the config directory
#
!includedir /etc/my.cnf.d
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值