Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Connect MySQL

Connect Horizon Epoch to MySQL databases.

CLI Configuration

# Add MySQL storage backend
epoch storage add mydb \
    --type mysql \
    --url "mysql://user:pass@localhost:3306/database"

Connection String Format

mysql://[user[:password]@][host][:port]/database[?param=value&...]

Common parameters:

  • ssl-mode - disabled, preferred, required, verify_ca, verify_identity
  • ssl-ca - Path to CA certificate
  • connect_timeout - Connection timeout in seconds

SSL/TLS Modes

ModeDescription
disabledNo SSL
preferredUse SSL if available (default)
requiredRequire SSL, don’t verify certificate
verify_caRequire SSL, verify CA
verify_identityRequire SSL, verify CA and hostname

With SSL

epoch storage add mydb \
    --type mysql \
    --url "mysql://user:pass@host/db?ssl-mode=required"

With Certificate Verification

epoch storage add mydb \
    --type mysql \
    --url "mysql://user:pass@host/db?ssl-mode=verify_ca&ssl-ca=/path/to/ca.pem"

Register Tables

epoch table add customers \
    --location "mysql://mydb/customers"

SSH Tunnel Support

MySQL connections support SSH tunneling for secure access:

epoch storage add mydb \
    --type mysql \
    --url "mysql://user:pass@localhost:3306/db" \
    --ssh-host "bastion.example.com" \
    --ssh-user "ec2-user" \
    --ssh-key "~/.ssh/id_rsa"

See SSH Tunnels for more details.

AWS RDS MySQL

# Standard connection
epoch storage add rds \
    --type mysql \
    --url "mysql://admin:pass@mydb.cluster.us-east-1.rds.amazonaws.com:3306/mydb?ssl-mode=required"

For IAM authentication, see AWS Secrets.

Troubleshooting

Connection Refused

  • Verify MySQL is running and accepting connections
  • Check host, port, and firewall rules
  • Verify user has remote access permissions

SSL Errors

  • Ensure SSL mode matches server configuration
  • For self-signed certs, use verify_ca with ssl-ca parameter

Authentication Failed

  • Verify username and password
  • Check user has access from your host ('user'@'%' vs 'user'@'localhost')