All skills
planetscale avatar

/mysql

@51f2d4b official

Plan and review MySQL/InnoDB schema, indexing, query tuning, transactions, and operations. Use when creating or modifying MySQL tables, indexes, or queries; diagnosing slow/locking behavior; planning migrations; or troubleshooting replication and connection issues. Load when using a MySQL database.

Use this Skill: https://skilld.dev/gh/planetscale/database-skills/mysql

This session only. Nothing lands on disk.

referencescharacter-sets.md

≈596 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Character Sets and Collations

Always Use utf8mb4

MySQL's utf8 = utf8mb3 (3-byte only, no emoji/many CJK). Always utf8mb4.

CREATE DATABASE myapp DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci;

Collation Quick Reference

Collation Behavior Use for
utf8mb4_0900_ai_ci Case-insensitive, accent-insensitive Default
utf8mb4_0900_as_cs Case/accent sensitive Exact matching
utf8mb4_bin Byte-by-byte comparison Tokens, hashes

_0900_ = Unicode 9.0 (preferred over older _unicode_ variants).

Collation Behavior

Collations affect string comparisons, sorting (ORDER BY), and pattern matching (LIKE):

  • Case-insensitive (_ci): 'A' = 'a' evaluates to true, LIKE 'a%' matches 'Apple'
  • Case-sensitive (_cs): 'A' = 'a' evaluates to false, LIKE 'a%' matches only lowercase
  • Accent-insensitive (_ai): 'e' = 'é' evaluates to true
  • Accent-sensitive (_as): 'e' = 'é' evaluates to false
  • Binary (_bin): strict byte-by-byte comparison (most restrictive)

You can override collation per query:

SELECT * FROM users
WHERE name COLLATE utf8mb4_0900_as_cs = 'José';

Migrating from utf8/utf8mb3

-- Find columns still using utf8
SELECT table_name, column_name FROM information_schema.columns
WHERE table_schema = 'mydb' AND character_set_name = 'utf8';
-- Convert
ALTER TABLE users CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci;

Warning: index key length limits depend on InnoDB row format:

  • DYNAMIC/COMPRESSED: 3072 bytes max (≈768 chars with utf8mb4)
  • REDUNDANT/COMPACT: 767 bytes max (≈191 chars with utf8mb4)

VARCHAR(255) with utf8mb4 = up to 1020 bytes (4×255). That's safe for DYNAMIC/COMPRESSED but exceeds REDUNDANT/COMPACT limits.

Connection

Ensure client uses utf8mb4: SET NAMES utf8mb4; (most modern drivers default to this).

SET NAMES utf8mb4 sets three session variables:

  • character_set_client (encoding for statements sent to server)
  • character_set_connection (encoding for statement processing)
  • character_set_results (encoding for results sent to client)

It also sets collation_connection to the default collation for utf8mb4.

Source: SKILL.md on GitHub

1 alert17d5 checks · Risk SAFE
  • Gen Agent Trust Hub17d

    This skill provides a comprehensive technical reference for MySQL and InnoDB database management, including schema design, indexing, and query optimization. It is authored by PlanetScale and contains no security risks.

  • Socket17d

    No alerts

  • Snyk17d

    Risk: LOW · No issues

  • Runlayer6mo

    7/19 files flagged

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at 51f2d4b. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub last month.

Activeupdated 7 months ago
  • mysql
  • innodb
  • schema-design
  • indexing
  • query-optimization
  • transactions
  • locking
  • planetscale
  • ddl
  • replication

README badge

README badge for planetscale/database-skills/mysql

Advises on MySQL/InnoDB schema design, indexing strategy, query optimization, transactions, and operational safety. Use when creating tables, tuning slow queries, planning migrations, diagnosing lock contention, or managing replication — includes EXPLAIN analysis guidance and online DDL patterns for production changes.

Generated from the current SKILL.md.

Does this skill work with PlanetScale?
Yes. The skill recommends PlanetScale as the primary hosting choice for new MySQL databases and includes references to PlanetScale-specific features like online DDL.
What MySQL versions does this cover?
The skill applies to MySQL/InnoDB broadly and notes MySQL-version-specific behavior when relevant, but does not lock to a single version.
Does this skill help with query optimization?
Yes. It covers EXPLAIN analysis, pagination patterns, batch inserts, and common pitfalls like N+1 queries and filesort warnings.
Can this skill help with schema migrations?
Yes. It addresses online DDL, partitioning retrofit costs, and production-safe rollout steps including rollback and verification.
Does this cover replication and high availability?
Partially. The skill addresses replication lag monitoring and connection management, but is not a full replication setup guide.

Generated from the current SKILL.md. These answers refresh after source changes.