# mysql-dba > MySQL database administration using a pure TypeScript/JavaScript protocol implementation. Use this when users need to connect to MySQL databases, run queries, manage users and permissions, backup databases, or perform other DBA tasks. No external MySQL client libraries required. - Author: Catherine Renelle - Repository: catrenelle/MySQL-DBA - Version: 20260125011429 - Stars: 0 - Forks: 0 - Last Updated: 2026-02-07 - Source: https://github.com/catrenelle/MySQL-DBA - Web: https://mule.run/skillshub/@@catrenelle/MySQL-DBA~mysql-dba:20260125011429 --- --- name: mysql-dba description: MySQL database administration using a pure TypeScript/JavaScript protocol implementation. Use this when users need to connect to MySQL databases, run queries, manage users and permissions, backup databases, or perform other DBA tasks. No external MySQL client libraries required. --- # MySQL DBA Skill A pure TypeScript/JavaScript MySQL protocol implementation for database administration tasks. No external dependencies required. ## Invocation ``` /mysql-dba [arguments] ``` Or use the script directly: ```bash node ./scripts/mysql-client.mjs [arguments] ``` ## Environment Variables Configure connection via environment variables: | Variable | Description | Default | |----------|-------------|---------| | `MYSQL_HOST` | Database server hostname | `localhost` | | `MYSQL_PORT` | Database server port | `3306` | | `MYSQL_USER` | Username for authentication | (required) | | `MYSQL_PASSWORD` | Password for authentication | (required) | | `MYSQL_DATABASE` | Default database to use | (optional) | If credentials are missing, the script will prompt interactively. ## Commands ### Query Operations | Command | Description | |---------|-------------| | `query ` | Execute SELECT query, return results as JSON | | `exec ` | Execute INSERT/UPDATE/DELETE, return affected rows | ### Transaction Management | Command | Description | |---------|-------------| | `begin` | Start a transaction | | `commit` | Commit current transaction | | `rollback` | Rollback current transaction | ### Prepared Statements | Command | Description | |---------|-------------| | `prepare ` | Prepare a statement, returns statement ID | | `execute [params...]` | Execute prepared statement with parameters | | `deallocate ` | Deallocate prepared statement | ### Schema Operations | Command | Description | |---------|-------------| | `databases` | List all databases | | `tables [database]` | List tables in database | | `describe ` | Show table structure | | `create-db ` | Create a new database | | `drop-db ` | Drop a database | ### User Administration | Command | Description | |---------|-------------| | `users` | List all users | | `create-user ` | Create a new user | | `drop-user ` | Drop a user | | `grant ` | Grant privileges | | `revoke ` | Revoke privileges | ### Stored Procedures | Command | Description | |---------|-------------| | `procedures [database]` | List stored procedures | | `call [args...]` | Call a stored procedure | ### Server Status | Command | Description | |---------|-------------| | `status` | Show server status | | `variables [pattern]` | Show server variables | | `processlist` | Show running processes | | `ping` | Test connection | ### Backup Operations | Command | Description | |---------|-------------| | `dump ` | Dump database (schema + data) | | `dump-schema ` | Dump database schema only | ## Output Format All commands return JSON output: **Success with data:** ```json { "status": "ok", "data": [...], "rowCount": 10 } ``` **Success with affected rows:** ```json { "status": "ok", "affectedRows": 1, "lastInsertId": 42 } ``` **Error:** ```json { "status": "error", "code": 1045, "message": "Access denied for user 'root'@'localhost'" } ``` ## Examples ```bash # Test connection node ./scripts/mysql-client.mjs ping # List databases node ./scripts/mysql-client.mjs databases # Run a query node ./scripts/mysql-client.mjs query "SELECT * FROM users LIMIT 10" # Create a user node ./scripts/mysql-client.mjs create-user newuser localhost secretpass # Dump a database node ./scripts/mysql-client.mjs dump myapp > backup.sql ``` ## Security Notes - Credentials are read from environment variables or prompted interactively - Never hardcode credentials in scripts - Use `MYSQL_PASSWORD` environment variable for automation - The implementation uses mysql_native_password authentication ## Implementation Details This skill implements the MySQL client/server protocol directly: - Packet framing (4-byte header: 3-byte length + 1-byte sequence) - mysql_native_password authentication (SHA1-based challenge-response) - COM_QUERY for text protocol queries - COM_STMT_PREPARE/EXECUTE for prepared statements - Result set parsing with column definitions and row data No external MySQL client libraries are required.