LearnMySQL is a Codex skill for secure MySQL operations. It provides a bundled Node.js CLI for alias-based connections, schema inspection, guarded SQL queries, approved writes, logical backups, TLS settings, and database selection at operation time.
Read this in Chinese: README_CN.md
- Manage MySQL server/account connections by alias instead of credential-bearing connection strings.
- Keep passwords out of chat, command arguments, environment variables, and project files.
- Store credentials through the official
mysql_config_editorlogin-path mechanism. - Keep the default database optional and select a database for each task.
- Inspect databases, tables, columns, and indexes with fixed read-only commands.
- Run guarded
SELECT,SHOW,DESCRIBE,DESC, andEXPLAINstatements. - Require explicit switches for writes, destructive SQL, SQL files, and backup overwrites.
- Create logical backups with safe
mysqldumpdefaults. - Support TLS verification, CA certificates, Unix sockets, and operation timeouts.
- Print concise human-readable output by default, or structured JSON with
--json.
- Node.js 18 or newer.
- The official MySQL client programs:
mysql,mysqldump, andmysql_config_editor.
On macOS with Homebrew:
brew install mysql-clientIf you want to invoke the MySQL programs directly, add Homebrew's keg-only client directory to PATH. LearnMySQL also checks the standard Apple Silicon and Intel Homebrew locations automatically.
Use mysql-ops doctor after installation to verify all three programs. The LearnMySQL installer does not install or start a MySQL server.
Run:
npx --yes github:LearnAIHubC/LearnMySQLThen restart Codex and use $mysql-ops.
To update an existing installation:
npx --yes github:LearnAIHubC/LearnMySQL --forceThe installer copies the skill into ${CODEX_HOME:-$HOME/.codex}/skills/mysql-ops and creates a launcher at ${CODEX_HOME:-$HOME/.codex}/bin/mysql-ops. Add that bin directory to PATH if you want to run mysql-ops without the full path. If you install with --dest, use the launcher path printed by the installer. The Codex skill name is mysql-ops. The UI display name is MySQL Ops.
Check the required client programs:
"${CODEX_HOME:-$HOME/.codex}/bin/mysql-ops" doctorCreate a connection alias in your own terminal:
"${CODEX_HOME:-$HOME/.codex}/bin/mysql-ops" configure app-prod \
--host db.example.com \
--port 3306 \
--user app_reader \
--ssl-mode VERIFY_IDENTITY \
--ssl-ca /absolute/path/ca.pem \
--description "production read-only"The real password is typed only into the hidden terminal prompt. Do not pass it as a flag, connection URI, or environment variable, and do not paste it into chat.
A database is not required when creating an alias. Select one later with --database, or intentionally save a preferred default by adding --database <name> to configure.
For a local Unix socket, use --socket /path/to/mysql.sock instead of --host and --port.
List sanitized aliases:
"${CODEX_HOME:-$HOME/.codex}/bin/mysql-ops" listTest a connection without selecting a database:
"${CODEX_HOME:-$HOME/.codex}/bin/mysql-ops" ping app-prodList databases, then choose one for the task:
"${CODEX_HOME:-$HOME/.codex}/bin/mysql-ops" databases app-prod
"${CODEX_HOME:-$HOME/.codex}/bin/mysql-ops" tables app-prod --database appDescribe a table:
"${CODEX_HOME:-$HOME/.codex}/bin/mysql-ops" describe app-prod \
--database app \
--table usersRun a read-only query:
"${CODEX_HOME:-$HOME/.codex}/bin/mysql-ops" query app-prod \
--database app \
--sql "SELECT id, email FROM users ORDER BY id DESC LIMIT 20"Use standard input for complex SQL:
"${CODEX_HOME:-$HOME/.codex}/bin/mysql-ops" query app-prod \
--database app \
--stdin --json <<'SQL'
SELECT status, COUNT(*) AS total
FROM orders
GROUP BY status;
SQLAfter reviewing and approving a write, run it with the required acknowledgement:
"${CODEX_HOME:-$HOME/.codex}/bin/mysql-ops" execute app-staging \
--database app \
--stdin --allow-write <<'SQL'
UPDATE feature_flags
SET enabled = 1
WHERE name = 'new_checkout';
SQLCreate a logical backup without overwriting an existing file:
"${CODEX_HOME:-$HOME/.codex}/bin/mysql-ops" dump app-prod \
--database app \
--output /absolute/path/app-backup.sqlLearnMySQL never accepts passwords through flags, MYSQL_PWD, connection URIs, or generated SQL files. It delegates password prompting and storage to the official mysql_config_editor program. MySQL describes .mylogin.cnf as obfuscated storage that prevents accidental cleartext exposure, not as protection from a determined attacker with access to the machine.
Alias metadata under ${CODEX_HOME:-$HOME/.codex}/mysql-ops/config.json contains only non-secret settings such as descriptions, preferred databases, TLS modes, and timeouts. Raw host, user, and port overrides are rejected during normal alias operations.
The CLI read-only check is a syntactic guard, not a database authorization boundary. Use a dedicated least-privilege account. Writes and destructive operations require explicit acknowledgement switches, and backup files are not overwritten by default.
bin/install.mjs
package.json
skills/mysql-ops/
|-- SKILL.md
|-- agents/openai.yaml
`-- scripts/mysql-ops.mjs
test/
|-- install.test.mjs
`-- mysql-ops.test.mjs
Validate the skill metadata:
python3 ~/.codex/skills/.system/skill-creator/scripts/quick_validate.py skills/mysql-opsCheck the CLI syntax and run the test suite:
node --check skills/mysql-ops/scripts/mysql-ops.mjs
npm testThe CLI tests use stub MySQL programs and do not connect to a real database.
Preview the npm package contents:
npm pack --dry-run- LINUX DO - A new ideal community and gathering place for technology enthusiasts.
MIT License. See LICENSE.