如何查看MySQL binlog日志

1、查看MySQL是否开启binlog日志

SQL:show variables like '%log_bin%';

log_bin:on 是开启状态

若是OFF,则需要开启binlog日志。

开启方式:打开mysql配置文件my.cnf,在[mysqlId]下面增加

log-bin=mysql-bin

查看binlog日志

mysql 复制代码
mysql> show binlog events ``in 'mysql-bin.000002'``;#查看指定binlog文件的内容 
mysql> show binary logs; #获取binlog文件列表 
mysql> show master status; #查看当前正在写入的binlog文件
mysql> show binary logs; #获取binlog文件列表 
mysql> flush logs;#刷新日志时,会生成新的binlog文件

若是执行SQL报错如下,则是权限不够。需要进行添加权限。

SQL 错误 [1227] [42000]: Access denied; you need (at least one of ) the SUPER, REPLICATION CLIENT privilege(s) for this operation

相关推荐
历程里程碑38 分钟前
MySQL事务深度解析:ACID到MVCC实战+万字长文解析
开发语言·数据结构·数据库·c++·sql·mysql·排序算法
橄榄熊39 分钟前
docker MySQL 密码报错,重新修改保留原样的数据
mysql·docker·容器
m0_737539371 小时前
MYSQL源码安装和备份
数据库·mysql·adb
xxjj998a2 小时前
MySQL无法连接到本地localhost的解决办法2024.11.8
数据库·mysql·adb
李少兄2 小时前
如何创建MySQL索引
数据库·mysql
m0_737539372 小时前
mysql的理论和使用
数据库·mysql
JoshRen3 小时前
Python使用PyMySQL操作MySQL完整指南
数据库·python·mysql
2601_949816223 小时前
MySQL 启动失败 (code=exited, status=1FAILURE) 异常解决方案
数据库·mysql
麻辣大虾3 小时前
SQL语言五大分类
数据库·sql·mysql
NaMM CHIN3 小时前
mysql的分区表
数据库·mysql