{"id":43252,"library":"mysql-binlog-events","title":"mysql-binlog-events","description":"A MySQL binlog listener library built on top of zongji. Version 0.1.18. It provides event-based access to MySQL binary log changes (row-based replication events) such as insert, update, delete, and table map events. Supports TypeScript types. Compared to alternatives like zongji, this package simplifies the API with a more event-driven approach. Release cadence is irregular; last update was several years ago.","status":"maintenance","version":"0.1.18","language":"javascript","source_language":"en","source_url":"https://github.com/qwertymypass/mysql-binlog-events","tags":["javascript","node.js","mysql","binlog","events","watcher","typescript"],"install":[{"cmd":"npm install mysql-binlog-events","lang":"bash","label":"npm"},{"cmd":"yarn add mysql-binlog-events","lang":"bash","label":"yarn"},{"cmd":"pnpm add mysql-binlog-events","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core dependency that handles MySQL binlog connection and parsing; this package wraps zongji's API","package":"zongji","optional":false},{"reason":"Used for MySQL connection (zongji depends on it)","package":"mysql2","optional":false}],"imports":[{"note":"ESM import is recommended. CommonJS require with destructuring may fail if module uses ESM only.","wrong":"const BinlogWatcher = require('mysql-binlog-events').BinlogWatcher","symbol":"BinlogWatcher","correct":"import { BinlogWatcher } from 'mysql-binlog-events'"},{"note":"The package exports a default class BinlogWatcher. CommonJS require works if the module is CJS-compatible, but ES import is safer.","wrong":"const BinlogWatcher = require('mysql-binlog-events')","symbol":"default export (BinlogWatcher)","correct":"import BinlogWatcher from 'mysql-binlog-events'"},{"note":"For TypeScript users, import type for event interfaces. Not available in CJS.","wrong":null,"symbol":"BinlogEvent type","correct":"import type { BinlogEvent } from 'mysql-binlog-events'"},{"note":"For TypeScript users, import type for row-level event typings.","wrong":null,"symbol":"RowEvent type","correct":"import type { RowEvent } from 'mysql-binlog-events'"}],"quickstart":{"code":"import BinlogWatcher from 'mysql-binlog-events';\n\nconst watcher = new BinlogWatcher({\n  host: 'localhost',\n  port: 3306,\n  user: 'root',\n  password: process.env.MYSQL_PASSWORD ?? '',\n  serverId: 1, // must be unique among replicas\n  filename: 'mysql-bin.000001', // optional: start from a specific binlog file\n  position: 0 // optional: start position\n});\n\nwatcher.on('insert', (event) => {\n  console.log('Insert:', event);\n});\n\nwatcher.on('update', (event) => {\n  console.log('Update:', event);\n});\n\nwatcher.on('delete', (event) => {\n  console.log('Delete:', event);\n});\n\nwatcher.on('error', (err) => {\n  console.error('Error:', err);\n});\n\nwatcher.start();","lang":"typescript","description":"Creates a BinlogWatcher instance, connects to MySQL, listens for binlog events (insert, update, delete) and handles errors."},"warnings":[{"fix":"Set MySQL config: binlog_format=ROW, log_bin=ON, and ensure server_id is set.","message":"MySQL server must have binlog_format = ROW and log_bin enabled. Without these, the watcher will not receive events.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Pass a unique serverId to the constructor.","message":"Each replica must have a unique server_id. Duplicate server_id causes connection issues.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Ensure MySQL binlog_format is set to ROW.","message":"The watcher only supports row-based binlog events. Statement-based or mixed mode may not work correctly.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Consider alternative libraries like @rodrigogs/mysql-events or direct use of mysql2 if needed.","message":"zongji (core dependency) has been archived. Future MySQL versions may break compatibility.","severity":"deprecated","affected_versions":">=0.0.0"}],"env_vars":null,"search_vec":"'0.1.18':16 'access':22 'ago':71 'altern':47 'api':54 'approach':61 'base':21,30 'binari':25 'binlog':3,7,75 'built':10 'cadenc':63 'chang':27 'compar':45 'delet':37 'driven':60 'event':4,20,32,41,59,76 'event-bas':19 'event-driven':58 'insert':35 'irregular':65 'javascript':72 'last':66 'librari':9 'like':48 'listen':8 'log':26 'map':40 'mysql':2,6,24,74 'mysql-binlog-ev':1 'node.js':73 'packag':51 'provid':18 'releas':62 'replic':31 'row':29 'row-bas':28 'sever':69 'simplifi':52 'support':42 'tabl':39 'top':12 'type':44 'typescript':43,78 'updat':36,67 'version':15 'watcher':77 'year':70 'zongji':14,49","created_at":"2026-06-05T16:58:54.907612+00:00","updated_at":"2026-06-05T16:58:54.907612+00:00","problems":[{"fix":"GRANT REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'root'@'localhost';","cause":"MySQL user lacks REPLICATION SLAVE and REPLICATION CLIENT privileges.","error":"Access denied for user 'root'@'localhost'"},{"fix":"Verify MySQL is running, host/port correct, and firewall allows connection.","cause":"MySQL server not running or incorrect credentials.","error":"Cannot connect to MySQL server on 'localhost:3306'"},{"fix":"Use import BinlogWatcher from 'mysql-binlog-events' or const { BinlogWatcher } = require('mysql-binlog-events')","cause":"Using CommonJS require without default import access.","error":"TypeError: watcher.on is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/qwertymypass/mysql-binlog-events#readme","github":"https://github.com/qwertymypass/mysql-binlog-events","docs":null,"changelog":null,"pypi":null,"npm":"mysql-binlog-events","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}