MySQL 8.0关闭binlog(二进制日志)

数据库 1 年前 回复

, , , ,

在my.ini或my.cnf的[mysqld]部分添加

skip-log-bin

然后重启mysql即可。

如果你安装的是docker,且没有映射到本地磁盘,可以这样操作:
1、用SSH连接你的群晖;

2、进入群晖docker:

sudo docker exec -it mysql /bin/bash

mysql是你的docker名。

3、查看你的mysql默认二进制日志是否打开:

mysql -uroot

输入密码,进入mysql命令,输入 show variables like 'log_bin'; 注意后面有个分号;

mysql> show variables like 'log_bin';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| log_bin | ON |
+---------------+-------+
1 row in set (0.03 sec)
上面显示默认是打开的。

4、清除日志:

reset master;

5、退出mysql命令,用以下命令将skip-log-bin加入到my.cnf配置文件中,因为docker没有vi编辑器,要么你安装一个,要么你跟我学。

cp /etc/my.cnf /etc/my.cnf.old #备份my.cnf
cat /etc/my.cnf                #查看my.cnf,然后你要复制下来里面内容
echo -e '\n# For advice on how to change settings please see\n# http://dev.mysql.com/doc/refman/8.0/en/server-configuration-defaults.html\n\n[mysqld]\n#\n# Remove leading # and set to the amount of RAM for the most important data\n# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.\n# innodb_buffer_pool_size = 128M\n#\n# Remove leading # to turn on a very important data integrity option: logging\n# changes to the binary log between backups.\n# log_bin\n#\n# Remove leading # to set options mainly useful for reporting servers.\n# The server defaults are faster for transactions and fast SELECTs.\n# Adjust sizes as needed, experiment to find the optimal values.\n# join_buffer_size = 128M\n# sort_buffer_size = 2M\n# read_rnd_buffer_size = 2M\n# Remove leading # to revert to previous value for default_authentication_plugin,\n# this will increase compatibility with older clients. For background, see:\n# https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_default_authentication_plugin\n# default-authentication-plugin=mysql_native_password\nskip-host-cache\nskip-log-bin\nskip-name-resolve\ndatadir=/var/lib/mysql\nsocket=/var/run/mysqld/mysqld.sock\nsecure-file-priv=/var/lib/mysql-files\nuser=mysql\n\npid-file=/var/run/mysqld/mysqld.pid\n[client]\nsocket=/var/run/mysqld/mysqld.sock\n\n!includedir /etc/mysql/conf.d/\n' > /etc/my.cnf

将skip-log-bin用\n隔开放在[mysqld]后面即可。以上是我的mysql配置文件,仅供参考!

支付宝打赏微信打赏

如果此文对你有帮助,欢迎打赏作者。

发表评论

欢迎回来 (打开)

(必填)