A pure JavaScript MySQL protocol implementation for database administration tasks. No external MySQL client libraries required - it implements the MySQL wire protocol directly using only Node.js built-in modules.
/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 MySQL connection details via environment variables:
| Variable | Description | Default |
|---|---|---|
MYSQL_HOST |
Server hostname | localhost |
MYSQL_PORT |
Server port | 3306 |
MYSQL_USER |
Username | (required) |
MYSQL_PASSWORD |
Password | (required) |
MYSQL_DATABASE |
Default database | (optional) |
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
dump <database>- Full database dump (schema + data)dump-schema <database>- Schema only dump
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.sqlThis skill implements the MySQL client/server protocol from scratch:
- Packet framing: 4-byte header (3-byte length + 1-byte sequence ID)
- Authentication: mysql_native_password (SHA1-based challenge-response)
- Commands: COM_QUERY, COM_STMT_PREPARE, COM_STMT_EXECUTE, COM_PING, etc.
- Result parsing: Column definitions, row data, OK/ERR/EOF packets
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 - The implementation supports mysql_native_password authentication
- Consider using read-only users for query-only operations
MIT