查询 binglog状态
root@ubuntu:~# docker run --rm -it mysql:latest mysql -u'root' -p'qwe1qaz' -P 3306 -h10.193.34.24
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.34 MySQL Community Server (GPL)
Copyright (c) 2000, 2025, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> SHOW VARIABLES LIKE 'log_bin';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| log_bin | OFF |
+---------------+-------+
1 row in set (0.028 sec)
更改mysql配置文件无效, mysql启动方式为docker
查询启动加载的配置文件
mysql> SHOW VARIABLES LIKE 'config_file';
Empty set (0.029 sec)
mysql>
# 查看 MySQL 配置文件搜索顺序
root@e4e4d16e78f6:/# mysql --help | grep "Default options" -A 1
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf ~/.my.cnf
root@e4e4d16e78f6:/#
# /etc/my.cnf /etc/mysql/my.cnf ~/.my.cnf 三个配置文件都没加载进来
echo '''[mysqld]
log-bin = /var/lib/mysql/mysql-bin
server-id = 1
expire-logs-days = 10
max-binlog-size = 100M
binlog-format = ROW
''' >> /etc/mysql/my.cnf
# 重启容器
mysql> SHOW VARIABLES LIKE 'log_bin';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| log_bin | ON |
+---------------+-------+
1 row in set (0.024 sec)
end