Connection URL Format
MySQL connections use the following URL format:URL Components
- user - MySQL username
- password - User password (optional)
- host - Database server hostname or IP address
- port - Database port (default: 3306)
- database - Database name
URLs with
localhost are automatically normalized to 127.0.0.1 for compatibility (source: mysql.rs:55-58).Setup
Configuration Examples
- Local Development
- Production
- Docker Compose
Features
Transaction Support
MySQL migrations run in transactions by default. To disable transactions for a specific migration, add a comment at the top:Schema Dumping
Geni automatically dumps your MySQL schema after each successful migration. The schema dump includes:- Tables - Table definitions with columns, data types, and defaults
- Views - View definitions
- Constraints - Primary keys, foreign keys, and unique constraints
- Indexes - Index definitions
- Comments - Table and column comments
INFORMATION_SCHEMA (source: mysql.rs:208-434).
MySQL schema dumping works without external tools by querying the information schema directly.
Wait Timeout
Geni can wait for MySQL to be ready before running migrations:mysql.rs:33-53).
Parameterized Queries
MySQL uses? placeholders for prepared statements. Geni handles this automatically:
Database Operations
Create Database
CREATE DATABASE IF NOT EXISTS {database_name}
Drop Database
DROP DATABASE IF EXISTS {database_name}
Check Status
schema_migrations table.
Limitations
None. MySQL is fully supported with all Geni features.Examples
Basic Migration
Create a table in20240115120000_create_users.up.sql:
20240115120000_create_users.down.sql:
MySQL-Specific Features
Using MySQL features:Troubleshooting
Connection Issues
If you see connection errors, verify:- MySQL is running and accessible
- Hostname and port are correct (default: 3306)
- User credentials are valid
- Database exists (or use
geni create) - User has appropriate permissions
Localhost Resolution
Geni automatically convertslocalhost to 127.0.0.1 in MySQL URLs. If you need to use a Unix socket instead, use the full path:
Migration Table
Geni creates aschema_migrations table to track applied migrations:
Differences from PostgreSQL
- Uses
?for parameterized queries instead of$1,$2 - Includes
IF NOT EXISTS/IF EXISTSin database operations - Auto-increments use
AUTO_INCREMENTinstead ofSERIAL - Schema dumping uses
INFORMATION_SCHEMAinstead of system catalogs