mysql数据库如何使用工具binlog2sql解析binlog

您所在的位置:网站首页 二进制binlog日志怎么查看 mysql数据库如何使用工具binlog2sql解析binlog

mysql数据库如何使用工具binlog2sql解析binlog

2023-06-27 00:41| 来源: 网络整理| 查看: 265

一 root用户授权

GRANT SELECT, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'root'@'%'; 

二 参数文件my.cnf添加二进制日志功能

log_bin                  = /kingdee/mysql/mysql3307/log/binlog/mysql_bin_30001

max_binlog_size   = 512M

binlog_format      = row

注意:目录和大小可以根据自己的环境定义

三 验证日志是否开启

show variables like '%log_bin%';

四 查看数据库当前日志

show master status;

show master logs;

五 binlog日志解析 

python /tmp/binlog2sql/binlog2sql/binlog2sql.py -h192.168.56.103 -P3306 -uroot -proot -d lanhai_fi -t test --start-file=mysql-bin.000001 > /tmp/lanhai_fi.sql

参数解读如下

python:用的python编译器

/tmp/binlog2sql/binlog2sql/binlog2sql.py:binlog2sql下载的binlog2sql.py目录

-h192.168.56.103:主机ip

-P3306:端口号,这里的P是大写。

-uroot:用户名为root

-proot:密码为root

-d lanhai_fi:数据库名

-t test:对test表进行操作

–start-file=mysql-bin.000001:从哪个二进制文件开始

/tmp/lanhai_fi.sql:重定向到/tmp目录下并生成名字为lanhai_fi后缀为.sql的文件



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3