Mysql opens binlog log

Mysql security settings-open binlog log

Insert picture description here

Introduction to binlog:

binlog是二进制文件;
binlog记录了数据库的所有dml操作;
通过binlog日志可以进行数据恢复操作;

binlog configuration:

  • Modify the configuration file of the my.cnf database and configure binlog;
  • Restart the mysql service;

Check whether the binlog log is enabled in the mysql database:

 show variables like 'log_bin';
 mysql>  show variables like 'log_bin';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| log_bin       | OFF   |
+---------------+-------+
1 row in set (0.08 sec)

The following configuration files in the mysql configuration file my.cnf file:

[mysqld]
#设置日志格式
binlog_format = mixed
#设置日志路径,注意路经需要mysql用户有权限
log-bin = /var/logmysql-bin
#设置binlog清理时间
expire_logs_days = 7
#binlog每个日志文件大小
max_binlog_size = 100M
#binlog缓存大小
binlog_cache_size = 4M
#最大binlog缓存大小
max_binlog_cache_size = 512M

Pay attention to assign permissions to the folder where the log files are stored:

chown mysql:mysql -R /var/log

Restart the mysql service:

 /bin/systemctl restart  mysqld.service

The service started successfully;

mysql>  show variables like 'log_bin';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| log_bin       | ON    |
+---------------+-------+
1 row in set (0.16 sec)

Guess you like

Origin blog.csdn.net/qq_43549291/article/details/109678101