Install
openclaw skills install mysqlWrite correct MySQL queries with proper character sets, indexing, transactions, and production patterns.
openclaw skills install mysql| Topic | File |
|---|---|
| Index design deep dive | indexes.md |
| Transactions and locking | transactions.md |
| Query optimization | queries.md |
| Production config | production.md |
utf8 is broken—only 3 bytes, can't store emoji; always use utf8mb4utf8mb4_unicode_ci for case-insensitive sorting; utf8mb4_bin for exact byte comparisonSET NAMES utf8mb4 or connection string parameterWHERE active = true in index definitionINDEX (description(100))—without length, errorINDEX (a, b, c) to cover cINSERT ... ON DUPLICATE KEY UPDATE—not standard SQL; needs unique key conflictLAST_INSERT_ID() for auto-increment—no RETURNING clause like PostgreSQLREPLACE INTO deletes then inserts—changes auto-increment ID, triggers DELETE cascadeSELECT ... FOR UPDATE locks rows—but gap locks may lock more than expectedinnodb_lock_wait_timeout for adjustmentFOR UPDATE SKIP LOCKED exists in MySQL 8+—queue patternsql_mode includes ONLY_FULL_GROUP_BY by default in MySQL 5.7+ANY_VALUE(column) to silence error when you know values are sameSHOW TABLE STATUS—convert with ALTER TABLE ... ENGINE=InnoDBLIMIT offset, count different order than PostgreSQL's LIMIT count OFFSET offset!= and <> both work; prefer <> for SQL standardALTER TABLE commits immediately, can't rollbackTINYINT(1)—TRUE/FALSE are just 1/0IFNULL(a, b) instead of COALESCE for two args—though COALESCE workswait_timeout kills idle connections—default 8 hours; pooler may not noticemax_connections default 151—often too low; each uses memorySHOW PROCESSLIST to see active connections—kill long-running with KILL <id>Seconds_Behind_Master before relying on replica readsEXPLAIN ANALYZE only in MySQL 8.0.18+—older versions just EXPLAIN without actual timesOPTIMIZE TABLE for fragmented tables—locks table; use pt-online-schema-change for big tablesinnodb_buffer_pool_size—set to 70-80% of RAM for dedicated DB server