MySQL Configuration
Connect to MySQL databases for transactional data, structured queries, and OLTP systems.
Connection Parameters
Required Fields
| Field | Description | Example |
|---|---|---|
| Host | Database hostname | mysql.example.com |
| Port | MySQL port (default: 3306) | 3306 |
| Database | Database name | myapp |
| Username | Database user | app_user |
| Password | User password (encrypted at rest) |
Optional Fields
| Field | Description |
|---|---|
| Use SSL | Enable for secure connections (recommended for production) |
Connection String Format
mysql://user:***@host:3306/database
Configuration Example
When creating a MySQL data source, provide the following information:
| Field | Example Value | Notes |
|---|---|---|
| Data source label | prod-mysql | Kebab-case unique identifier (used as both name and label) |
| Host | mysql.example.com | Database hostname |
| Port | 3306 | Default MySQL port |
| Database | myapp | Database name |
| Username | app_user | Database user |
| Password | password | Encrypted at rest |
| Use SSL | Enabled | Recommended for production |
Test Connection
Test Connection signs in with the username and password, runs SELECT 1 and gives up after 10 seconds. With Use SSL the connection is encrypted. A refused username or password fails with "The credentials were not accepted: check the username and password, or the key or token."; a host that cannot be reached says so.
SingleStore data sources (MySQL wire protocol) are tested the same way.
Schema Discovery
MySQL has full native schema discovery support. On the Metadata tab, Fetch Metadata returns:
- Tables: All tables in the selected database (via
SHOW TABLES) - Databases: All non-system databases (excluding
information_schema,performance_schema,mysql,sys) - Size: Total data + index size from
information_schema.tables - Row count: Approximate row count from
information_schema.tables
Column-Level Metadata
You can fetch column details for individual tables, which returns:
- Column name, data type, and column type
- Nullability
- Column key (PRIMARY, etc.)
- Default values and extra information (e.g., auto_increment)
- Table row count and size
Usage in Workflows and Apps (STRONGLY_SERVICES)
When a MySQL data source is attached to a workflow or app, its decrypted connection details are injected via STRONGLY_SERVICES under services.datasources.mysql (one entry per configured connection):
{
"services": {
"datasources": {
"mysql": [
{
"id": "abc123",
"name": "prod-mysql",
"type": "mysql",
"category": "data-source",
"status": "connected",
"connection": {
"host": "mysql.example.com",
"port": 3306,
"database": "myapp",
"ssl": { "enabled": true }
},
"auth": {
"method": "username_password",
"credentials": {
"username": "app_user",
"password": "<password>"
}
}
}
]
}
}
}
Python Example
import os, json
import mysql.connector
# Parse STRONGLY_SERVICES environment variable
services = json.loads(os.environ['STRONGLY_SERVICES'])
# Pick your MySQL data source by name (its label)
my = next(
d for d in services['services']['datasources']['mysql']
if d['name'] == 'prod-mysql'
)
# Connect using the connection and auth sections
conn = mysql.connector.connect(
host=my['connection']['host'],
port=my['connection']['port'],
database=my['connection']['database'],
user=my['auth']['credentials']['username'],
password=my['auth']['credentials']['password']
)
# Execute queries
cursor = conn.cursor()
cursor.execute("SELECT * FROM users WHERE active = 1")
users = cursor.fetchall()
Node.js Example
const mysql = require('mysql2/promise');
// Parse STRONGLY_SERVICES environment variable
const services = JSON.parse(process.env.STRONGLY_SERVICES);
const my = services.services.datasources.mysql
.find(d => d.name === 'prod-mysql');
// Create connection using the connection and auth sections
const connection = await mysql.createConnection({
host: my.connection.host,
port: my.connection.port,
database: my.connection.database,
user: my.auth.credentials.username,
password: my.auth.credentials.password,
ssl: my.connection.ssl && my.connection.ssl.enabled ? {} : false
});
// Execute query
const [rows] = await connection.execute('SELECT * FROM users WHERE active = 1');
console.log(rows);
PHP Example
<?php
// Parse STRONGLY_SERVICES environment variable
$services = json_decode(getenv('STRONGLY_SERVICES'), true);
// Pick your MySQL data source by name (its label)
$my = null;
foreach ($services['services']['datasources']['mysql'] as $ds) {
if ($ds['name'] === 'prod-mysql') { $my = $ds; break; }
}
// Connect using the connection and auth sections
$mysqli = new mysqli(
$my['connection']['host'],
$my['auth']['credentials']['username'],
$my['auth']['credentials']['password'],
$my['connection']['database'],
$my['connection']['port']
);
// Check connection
if ($mysqli->connect_error) {
die('Connection failed: ' . $mysqli->connect_error);
}
// Execute query
$result = $mysqli->query("SELECT * FROM users WHERE active = 1");
$users = $result->fetch_all(MYSQLI_ASSOC);
SSL/TLS Configuration
Enabling SSL
To enable SSL for encrypted connections:
- Check the Use SSL checkbox when configuring the data source
- Ensure your MySQL server is configured with SSL certificates
- Verify the MySQL server requires SSL:
SHOW VARIABLES LIKE 'have_ssl';
SSL Certificate Verification
For production environments, you may want to verify SSL certificates:
# Python with certificate verification
import ssl
ssl_context = ssl.create_default_context()
ssl_context.check_hostname = True
ssl_context.verify_mode = ssl.CERT_REQUIRED
conn = mysql.connector.connect(
host=my['host'],
port=my['port'],
database=my['database'],
user=my['username'],
password=my['password'],
ssl_disabled=False,
ssl_ca='/path/to/ca-cert.pem'
)
Common Issues
Connection Refused
- Verify the host and port are correct
- Check firewall rules allow connections
- Ensure MySQL is listening on the correct interface (check
bind-addressin my.cnf)
Access Denied
The test says "The credentials were not accepted".
- Verify username and password are correct
- Check user permissions:
SHOW GRANTS FOR 'username'@'host'; - Ensure the user is allowed to connect from the platform's IP address
- Grant necessary privileges:
GRANT ALL PRIVILEGES ON database.* TO 'username'@'host';
Database Not Found
- Verify the database name is correct (case-sensitive on some systems)
- Check if the database exists:
SHOW DATABASES; - Create the database if needed:
CREATE DATABASE myapp;
Too Many Connections
- Check current connections:
SHOW PROCESSLIST; - Increase
max_connectionsin my.cnf if needed - Use connection pooling in your application
Best Practices
- Use SSL in Production: Always enable SSL for production databases
- Least Privilege: Create dedicated users with minimal required permissions
- Connection Pooling: Use connection pooling for better performance
- Character Encoding: Set proper character encoding (UTF-8/utf8mb4)
- Monitor Connections: Track connection usage and monitor for connection leaks
- Regular Testing: Periodically test connections to ensure they remain valid
Character Set Configuration
For proper Unicode support, ensure your database and tables use utf8mb4:
-- Create database with utf8mb4
CREATE DATABASE myapp
CHARACTER SET utf8mb4
COLLATE utf8mb4_unicode_ci;
-- Convert existing database
ALTER DATABASE myapp
CHARACTER SET utf8mb4
COLLATE utf8mb4_unicode_ci;
-- Create table with utf8mb4
CREATE TABLE users (
id INT PRIMARY KEY,
name VARCHAR(255)
) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;