Implementation of MySQL authentication state storage for Baileys, a WhatsApp Web library. This package provides a MySQL-based authentication state handler that allows persisting Baileys authentication data (creds, keys, sessions) in a MySQL database. It is currently at version 1.5.4 and is maintained by bobslavtriev. Key differentiators include full TypeScript support with type definitions, seamless integration with mysql2 library, and support for managing multiple sessions via table prefix option. It is a lightweight connector that implements Baileys' AuthenticationState interface, making it easy to use MySQL as backend for WhatsApp bot sessions.
npm install mysql-baileysNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to create a MySQL connection pool and initialize the authentication state for Baileys using mysql-baileys.
Install mysql2: npm install mysql2
Set tablePrefix to a valid string or omit it to use default.
Pass distinct tablePrefix values for each session.
Do not manually alter the tables created by the package.
Update to latest Baileys v6 and use 'auth' instead of 'authentication'.
Run 'npm install mysql-baileys' and ensure your project uses ESM (type: 'module' in package.json or .mjs extension).
Replace 'mysql' with 'mysql2/promise' and ensure the pool is created with createPool.
Alter MySQL user: ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'; or update mysql2 connection options.
Ensure you import { useMySQLAuthState } from 'mysql-baileys' and call it correctly with the pool argument.