mysql-expert
MySQL/MariaDB administration: InnoDB internals, master-slave/group replication, partitioning, buffer pool and redo log tuning, online migrations with pt-online-schema-change, support for Aurora MySQL and RDS MySQL on AWS. Use when tuning InnoDB buffer pool, configuring replication, performing online schema changes, optimizing slow queries, or managing AWS RDS/Aurora MySQL. Trigger: MySQL InnoDB, pt-online-schema-change, buffer pool tuning, replication lag, Aurora MySQL. Do NOT trigger for: PostgreSQL schema design, MongoDB aggregation pipelines, general NoSQL database administration.
- License 许可
- MIT
- 最近更新
- 2026-08-27
- Stars
- ★ 1
- Forks
- 0
01 前言 Front Matter
- name
- mysql-expert
- license
- MIT
- metadata
- { "author": "Community", "status": "stable", "version": "1.0", "category": "data" }
- description
- MySQL/MariaDB administration: InnoDB internals, master-slave/group replication, partitioning, buffer pool and redo log tuning, online migrations with pt-online-schema-change, support for Aurora MySQL and RDS MySQL on AWS. Use when tuning InnoDB buffer pool, configuring replication, performing online schema changes, optimizing slow queries, or managing AWS RDS/Aurora MySQL. Trigger: MySQL InnoDB, pt-online-schema-change, buffer pool tuning, replication lag, Aurora MySQL. Do NOT trigger for: PostgreSQL schema design, MongoDB aggregation pipelines, general NoSQL database administration.
02 资源文件 3
- 参考文档evals/evals.json2.3 KB
- 参考文档references/pt-online-schema.md687 B
- 参考文档references/replication.md523 B
03 SKILL.md 正文
MySQL Expert
MySQL/MariaDB: InnoDB tuning, replication, and AWS managed.
Core Stack
- Database: MySQL 8.0 / MariaDB 10.6 / Amazon Aurora MySQL / RDS MySQL
- Engine: InnoDB (buffer pool, redo log, doublewrite buffer)
- Replication: Master-slave, Group Replication, Aurora read replicas
- Tools: pt-online-schema-change, mysqldump, mysqlbinlog
- JDBC: MySQL Connector/J
InnoDB Tuning
[mysqld]
innodb_buffer_pool_size = 70%_of_RAM # single most important param
innodb_log_file_size = 2G # larger = less checkpoint IO
innodb_flush_log_at_trx_commit = 1 # 1=ACID, 2=fast+crashable
innodb_flush_method = O_DIRECT # avoid double buffering
innodb_io_capacity = 2000 # SSD: 2000, HDD: 200
Replication
| Type | Use When |
|---|---|
| Async Master-Slave | Read scaling, reporting |
| Semi-Sync | Reduced data loss risk |
| Group Replication | HA with auto-failover |
| Aurora Read Replicas | AWS managed, <100ms lag |
Online Schema Changes
# NEVER ALTER TABLE directly on large tables (locks)
pt-online-schema-change \
--alter "ADD COLUMN external_id VARCHAR(64)" \
--execute \
D=appdb,t=items
Constraints
- NEVER run
ALTER TABLEon >1M rows without pt-online-schema-change - NEVER skip backups before schema changes
- NEVER use MyISAM engine (no transactions, crash-unsafe)
- ALWAYS monitor buffer pool hit rate (target: >99%)
- ALWAYS use parameterized queries (never string concat)
- NEVER disable
sql_modestrict mode (STRICT_TRANS_TABLES) - NEVER use
SELECT *in production queries (column drift breaks clients)
Security
- ALWAYS enforce TLS (ssl-mode=REQUIRED) for client connections — never plaintext auth
- ALWAYS grant least-privilege roles per service — never root or wildcard grants
- ALWAYS use parameterized queries to prevent SQL injection (OWASP 2025 A05 Injection)
- ALWAYS encrypt backups and enable KMS/CMK encryption for RDS/Aurora volumes
Overview
MySQL (InnoDB) is a transactional relational database for production workloads. This skill covers InnoDB tuning (buffer pool, redo log, flush methods), replication topology (async, semi-sync, Group Replication, Aurora), online schema changes via pt-online-schema-change, query optimization through EXPLAIN plan analysis, and AWS-managed MySQL deployment (RDS, Aurora).
Quick Reference
| Parameter | Recommended | Impact |
|---|---|---|
innodb_buffer_pool_size |
70% of RAM | Single most important InnoDB tuning |
innodb_log_file_size |
2GB | Reduces checkpoint IO frequency |
innodb_flush_log_at_trx_commit |
1 (ACID) / 2 (faster) | Durability vs performance trade-off |
innodb_flush_method |
O_DIRECT | Avoids OS double buffering |
innodb_io_capacity |
2000 (SSD) | Background IOPS limit |
max_connections |
200 (+ proxy) | Connection pool saturation guard |
Workflow
- Tune InnoDB — Set
innodb_buffer_pool_sizeto 70% of RAM. Setinnodb_log_file_sizeto 2GB. Setinnodb_flush_method=O_DIRECT. Verify withSHOW ENGINE INNODB STATUS\G. - Configure replication — Choose topology: async for reporting slaves, semi-sync for reduced data-loss risk, Group Replication for HA auto-failover, Aurora for AWS-managed HA.
- Perform online schema changes — Never
ALTER TABLEdirectly on >1M rows. Usept-online-schema-changewith--check-alterand--max-loadthresholds. Run during low traffic. - Optimize queries — Run
EXPLAINon slow queries. Verifytypeis notALL(full scan). Add covering indexes. Checkrows_examinedvs actual rows. - Monitor buffer pool — Target hit rate > 99% (
SHOW STATUS LIKE 'innodb_buffer_pool_reads%'). Increase buffer pool if hit rate drops below threshold. - Backup before changes — Always take a snapshot or
mysqldumpbefore schema changes. Test restore from backup regularly.
Anti-patterns
FAIL: Running ALTER TABLE directly on production tables >1M rows (acquires table lock).
-- BAD: Locks table for minutes/hours on large tables
ALTER TABLE items ADD COLUMN external_id VARCHAR(64);
# GOOD: pt-online-schema-change with zero-downtime
pt-online-schema-change --alter "ADD COLUMN external_id VARCHAR(64)" \
--execute D=appdb,t=items
FAIL: Using MyISAM engine (no transactions, table-level locking, crash-unsafe).
-- BAD: MyISAM — no transactions, data loss on crash
CREATE TABLE items (id INT) ENGINE=MyISAM;
-- GOOD: InnoDB with ACID compliance
CREATE TABLE items (id INT) ENGINE=InnoDB;
FAIL: Using SELECT * in production code (column order drift breaks clients).
# BAD: SELECT * — breaks when columns are added/reordered
cursor.execute("SELECT * FROM items")
row = cursor.fetchone()
return {"id": row[0], "amount": row[1]}
# GOOD: Explicit column list — stable contract
cursor.execute("SELECT id, quantity, status FROM items")
References
| Resource | URL | Last verified |
|---|---|---|
| MySQL 8.0 — InnoDB Tuning Guide | https://dev.mysql.com/doc/refman/8.0/en/innodb-tuning.html | 2026-05-25 |
| Percona Toolkit — pt-online-schema-change | https://docs.percona.com/percona-toolkit/pt-online-schema-change.html | 2026-05-25 |
| Amazon Aurora MySQL — Best Practices | https://docs.aws.amazon.com/AmazonRDS/latest/AuroraMySQLGuide/ | 2026-05-25 |
Verification Checklist
- [ ]
innodb_buffer_pool_sizeset to 70% of available RAM - [ ] Buffer pool hit rate > 99% confirmed via
SHOW STATUSmonitoring - [ ] Online schema changes use
pt-online-schema-changefor tables >1M rows - [ ] Backup taken before any schema change operation
- [ ] Replication topology chosen and verified (async/semi-sync/group per requirements)
- [ ] No MyISAM tables in production (all InnoDB for ACID compliance)
- [ ]
SELECT *eliminated from production queries (explicit column lists) - [ ] TLS required on all connections; least-privilege roles; parameterized queries only
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| Buffer pool hit rate < 95% | innodb_buffer_pool_size too small for working dataset |
Increase buffer pool size; consider data archiving or partitioning |
| Replication lag > 5 minutes | Slave running long read queries or under-provisioned | Optimize queries; use pt-slave-delay for reporting; scale up slave instance |
pt-online-schema-change fails with timeout |
Table has triggers or foreign key constraints | Add --alter-foreign-keys-method=auto; increase --chunk-time parameter |
| Known issue: Aurora MySQL read replica lag spikes during writer DDL | Aurora replicas pause apply during DDL on writer to maintain consistency | Schedule DDL during low traffic; use pt-online-schema-change which minimizes Aurora replica lag vs direct ALTER TABLE |
[WARN] Gotcha: utf8mb4 vs utf8mb3 character set causes index size limit errors |
MySQL utf8mb3 max index length is 767 bytes per column (3 bytes/char = 255 chars) |
Use utf8mb4 with ROW_FORMAT=DYNAMIC or COMPRESSED for longer varchar indexes; verify with SHOW CREATE TABLE |
04 同仓库更多 Skills
web-browsing-agent-expert
Web browsing for AI agents: driving a headless browser (Playwright, Puppeteer) from agent tooling, navigation and page-state grounding, DOM extraction and structured data capture, form interaction, session and cookie management, anti-bot mitigation awareness, and safe browsing rules (no PII exfiltration, respect robots and terms). Use when building a browsing tool or MCP server for an agent, teaching an agent to navigate and read web pages, extracting structured content from dynamic sites, or handling login walls and pagination in agent workflows. Trigger: web browsing agent, headless browser, Playwright MCP, Puppeteer, browser automation for agents, DOM extraction, page navigation, session management. Do NOT trigger for: end-to-end UI testing of an application (use playwright-expert); writing standalone scraping scripts for data pipelines (use python-expert); fetching a single public URL (use the fetch tool).
vector-databases
Design and operate vector databases for cloud-native AI features. Use when selecting between pgvector, Pinecone, or Weaviate for AI context layer or integration-hub; designing embedding schemas and index parameters; implementing ANN search with metadata filtering; managing embedding model versions; optimizing query latency; or debugging low retrieval quality. Pairs with rag-architecture for pipeline design and postgres-database-expert for pgvector specifics. Trigger: vector database, pgvector, Pinecone, Weaviate, embedding, ANN search, HNSW, cosine similarity. Do NOT trigger for: relational SQL optimization, standard PostgreSQL schema design, Redis caching.
typescript-expert
Full-stack TypeScript stack for modern projects: frontend SSR/CSR with Next.js 14 App Router and React, backend APIs with Node.js (Express/Fastify), state management with Zustand/Redux Toolkit, unit and integration testing with Vitest/Jest + React Testing Library + MSW, and static analysis with ESLint/Prettier/tsc. Use when building React components or hooks, implementing Next.js App Router or Server Components, writing Node.js REST API handlers, implementing middleware (auth, rate-limit, logging), managing client state (Zustand/RTK), writing frontend/backend tests, or running TypeScript linting/type checks. Trigger: TypeScript, Next.js, React, Zustand, Node.js, Express, Fastify, MSW, Vitest. Do NOT trigger for: Python backend development, Go microservices, iOS/mobile development.
tool-usage
Guide correct tool selection, design, and orchestration for AI agents. Use when choosing between dedicated vs Bash tools, designing MCP tool interfaces, naming tool parameters, handling tool response limits, orchestrating parallel vs sequential calls, evaluating tool accuracy, applying ACI design principles, selecting workflow patterns, or reading/filtering/transforming/generating structured data (JSON, YAML, CSV, TOML, XML). Trigger: tool selection, MCP tool design, orchestration, ACI, parallel execution, composite tool, structured data, jq, yq, dasel, mlr, csvkit. Do NOT trigger for: writing application business logic, domain-specific development (route to domain skill), database migrations.
token-efficiency
Enforce token-efficient output, compression, caching, and model routing. Use when calibrating response verbosity, applying compression strategies to logs or RAG chunks, routing tasks to the right model tier, setting thinking budgets, enforcing word limits, compressing context before reinitiation, applying KV-cache ordering, masking tool output observations, or applying clarification-first protocol before irreversible actions. Trigger: token efficiency, compression, model routing, thinking budget, KV-cache, clarification protocol. Do NOT trigger for: non-agent tooling, CI/CD pipeline scripting, infrastructure provisioning.
time-series-db
Time-series database patterns for cloud-native metrics and analytics: TimescaleDB, InfluxDB, and Amazon Timestream selection; continuous aggregates, retention policies, downsampling, and integration with Prometheus/Grafana. Use when storing business metrics over time, building custom business dashboards, designing high-frequency event storage, or querying time-bucketed aggregations. Trigger: time-series, TimescaleDB, InfluxDB, Prometheus, Grafana, hypertable, continuous aggregate, retention policy. Do NOT trigger for: relational PostgreSQL schema design, NoSQL document stores, Kafka event streaming.