MySQL Primer
A focused walkthrough on getting MySQL wired into your Meridian workflows. This primer covers the essentials: spinning up a local instance, modeling a schema that scales, and writing queries that stay fast as your data grows past the easy-mode threshold.
1. Install and connect
Grab MySQL 8.x from the official archive or your package manager. Once the daemon is running, confirm you can authenticate with the root account before creating an app-scoped user with the minimum privileges required for your service.
mysql -u root -p CREATE DATABASE meridian CHARACTER SET utf8mb4; CREATE USER 'app'@'%' IDENTIFIED BY 'changeme'; GRANT ALL ON meridian.* TO 'app'@'%'; FLUSH PRIVILEGES;
2. Model your schema
Favor narrow tables with explicit foreign keys over wide denormalized blobs. Use BIGINT primary keys when you expect growth, timestamps stored as UTC, andutf8mb4 everywhere so emoji and international characters round-trip cleanly.
- Index the columns you filter and join on, not every column.
- Prefer
DECIMALfor money, never floats. - Add
created_atandupdated_aton every table.
3. Query like you mean it
Run EXPLAIN on any query that touches more than a few thousand rows. A missing index is the single most common cause of dashboards that crawl. Aim for the optimizer to report const, ref, or range access types and avoid ALL.
EXPLAIN SELECT u.email, COUNT(o.id) AS orders FROM users u LEFT JOIN orders o ON o.user_id = u.id WHERE u.created_at >= '2026-01-01' GROUP BY u.id ORDER BY orders DESC LIMIT 50;