A pure JavaScript MySQL/MariaDB protocol implementation for database administration tasks. No external MySQL client libraries required - it implements the MySQL wire protocol (also spoken by MariaDB) directly using only Node.js built-in modules.
Fully compatible with MySQL 5.7/8.x and MariaDB 10.x/11.x, including cross-flavor backup and restore (a MySQL dump restores onto MariaDB and vice versa, with incompatible statements rewritten automatically).
/plugin marketplace add catrenelle/mysql-dba
/plugin install mysql-dba
Restart Claude Code after installation to load the plugin.
git clone https://github.com/catrenelle/MySQL-DBA .claude/plugins/mysql-dbagit clone https://github.com/catrenelle/MySQL-DBA ~/.claude/plugins/mysql-dbaThis makes the skill available across all your projects.
Once installed, invoke the skill in Claude Code:
/mysql-dba ping
/mysql-dba databases
/mysql-dba query "SELECT * FROM users LIMIT 10"
Or run the script directly:
node mysql-dba/scripts/mysql-client.mjs <command> [arguments]Set connection details via environment variables (MARIADB_* names work as aliases):
| Variable | Description | Default |
|---|---|---|
MYSQL_HOST |
Server hostname | localhost |
MYSQL_PORT |
Server port | 3306 |
MYSQL_USER |
Username | (required) |
MYSQL_PASSWORD |
Password (empty string = passwordless account) | (required) |
MYSQL_DATABASE |
Default database | (optional) |
MYSQL_ALLOW_CLEARTEXT |
Set to 1 to permit cleartext auth (PAM/LDAP) |
(off) |
If credentials are not set, the script will prompt interactively.
query <sql>- Execute SELECT, return JSON resultsexec <sql>- Execute INSERT/UPDATE/DELETE, return affected rows
databases- List all databasestables [database]- List tablesdescribe <table>- Show table structurecreate-db <name>- Create databasedrop-db <name>- Drop database
users- List all userscreate-user <user> <host> <password>- Create userdrop-user <user> <host>- Drop usergrant <privileges> <database> <user> <host>- Grant privilegesrevoke <privileges> <database> <user> <host>- Revoke privileges
begin- Start transactioncommit- Commit transactionrollback- Rollback transaction
prepare <sql>- Prepare statement (returns ID)execute <id> [params...]- Execute with parametersdeallocate <id>- Deallocate statement
status- Show server statusvariables [pattern]- Show server variablesprocesslist- Show running processesping- Test connection (reports server flavor + version)server-info- Show detected flavor (mysql/mariadb) and version
dump <database> [--compat mysql|mariadb]- Full database dump (schema + data)dump-schema <database> [--compat mysql|mariadb]- Schema only dumpimport <file.sql[.gz]> [--force] [--no-rewrite]- Restore a dump file (alias:restore)
import accepts plain and gzipped dumps (its own, mysqldump/mariadb-dump,
AutoMySQLBackup .sql.gz). It detects the target server's flavor and
automatically rewrites statements that don't run there (MySQL 8
utf8mb4_0900_* collations, /*!80xxx */ version-gated comments,
GTID_PURGED sets, MariaDB PAGE_CHECKSUM/Aria options), and strips
DEFINER clauses that require SUPER to restore. Data statements are never
modified.
All commands return JSON:
{
"status": "ok",
"data": [...],
"rowCount": 10
}Errors:
{
"status": "error",
"code": 1045,
"message": "Access denied..."
}# Test connection
node skills/mysql-dba/scripts/mysql-client.mjs ping
# List databases
node skills/mysql-dba/scripts/mysql-client.mjs databases
# Query with results
node skills/mysql-dba/scripts/mysql-client.mjs query "SELECT * FROM users WHERE active = 1"
# Create a user with privileges
node skills/mysql-dba/scripts/mysql-client.mjs create-user appuser localhost secretpass
node skills/mysql-dba/scripts/mysql-client.mjs grant "SELECT, INSERT, UPDATE" mydb appuser localhost
# Backup a database
node skills/mysql-dba/scripts/mysql-client.mjs dump myapp > backup.sql
# Restore it (works across MySQL <-> MariaDB)
node skills/mysql-dba/scripts/mysql-client.mjs import backup.sqlThis skill implements the MySQL client/server protocol (shared by MariaDB) from scratch:
- Packet framing: 4-byte header (3-byte length + 1-byte sequence ID), with splitting at the 16MB protocol limit
- Authentication: mysql_native_password and caching_sha2_password (MySQL 8 default), with AuthSwitchRequest and RSA full-auth handling
- MariaDB detection: unmasks the
5.5.5-version prefix and adapts dumps/imports to the server flavor - Commands: COM_QUERY, COM_STMT_PREPARE, COM_STMT_EXECUTE, COM_PING, etc.
- Result parsing: Column definitions, row data, OK/ERR/EOF packets
- Restore: dump-file statement splitting (strings, comments, DELIMITER) with automatic cross-flavor rewriting
No dependency on mysql, mysql2, or any native MySQL client libraries.
- Node.js 18+ (uses ES modules)
- MySQL 5.7+ or MariaDB 10.2+
- Store credentials in environment variables, never in code
- Use
MYSQL_PASSWORDenv var for automation - Supports mysql_native_password and caching_sha2_password authentication; cleartext auth requires explicit opt-in (
MYSQL_ALLOW_CLEARTEXT=1) - Consider using read-only users for query-only operations
MIT