Mysql8.0.25默认是开启binlog记录功能,会增加从库磁盘I/O等的压力,非必要开启,请关闭。
$sudo mysql -u root -p
mysql> show variables like 'log_bin';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| log_bin | ON |
+---------------+-------+
1 row in set (0.01 sec)
#查看现有的binlog日志
mysql> show master logs;
#手动清除binlog日志
mysql> reset master;
Query OK, 0 rows affected (0.01 sec)
关闭mysql binlog配置
#编辑文件mysqld.cnf,添加skip-log-bin,有些版本文件为my.cnf
$sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
[mysqld]
user = mysql
skip-log-bin
#重启mysql服务
$sudo systemctl restart mysql
#再次查看log_bin状态
$sudo mysql -u root -p
mysql> show variables like 'log_bin';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| log_bin | OFF |
+---------------+-------+
1 row in set (0.01 sec)
mysql> show master logs;
ERROR 1381 (HY000): You are not using binary logging
MySQL全量备份
#备份
mysqldump -h 主机名 -P 端口 -u 用户名 -p 数据库名 > 备份文件.sql
#恢复
mysql> source 备份文件.sql
网友评论