This guide explains how to connect to MySQL databases with Oxy. MySQL is one of the world’s most popular open-source relational database management systems.

Configuration Options

Add your MySQL configuration to config.yml. Here are all available parameters:

databases:
  - name: my_mysql_db       # Unique identifier for this connection
    type: mysql
    host: "localhost"       # MySQL server hostname or IP
    port: "3306"           # Port number (default: 3306)
    user: "root"           # Username for authentication
    password: <password>    # Direct password (not recommended)
    password_var: "MYSQL_PWD" # Environment variable containing password (recommended)
    database: "default"    # Database name to connect to

Example Configurations

1

Prepare password environment variable

Export the environment variable:

export MYSQL_PWD=<your password>

Or put it in .env file:

echo MYSQL_PWD=<your password> >> .env
2

Add MySQL configuration

databases:
  - name: local_db
    type: mysql
    host: "localhost"
    port: "3306"
    user: "dev_user"
    password_var: "MYSQL_PWD"
    database: "development"

Troubleshooting

  • Verify MySQL server is running: mysqladmin ping
  • Check connectivity: mysql -h hostname -u username -p
  • Common ports: 3306 (default), 33060 (X Protocol)
  • Ensure user has proper permissions: SHOW GRANTS