MySQL
MySQL is a widely-used open-source relational database management system known for its performance, reliability, and ease of use. Hyperterse provides full support for MySQL with connection pooling, character set configuration, transaction support, and all standard SQL features including joins, aggregations, and subqueries.
Connecting to your server
Section titled “Connecting to your server”MySQL adapters use the Go MySQL driver connection format:
adapters: my_mysql: connector: mysql connection_string: 'user:password@tcp(host:3306)/database'Connection parameters
Section titled “Connection parameters”Add parameters to the connection string for fine-tuning:
connection_string: 'user:pass@tcp(host:3306)/db?charset=utf8mb4&parseTime=true&loc=UTC&timeout=10s'Adapter options
Section titled “Adapter options”Configure connection pooling and other settings:
adapters: production_db: connector: mysql connection_string: 'user:pass@tcp(host:3306)/db' options: max_connections: '10' charset: 'utf8mb4'For a complete list of connection parameters, see the MySQL connection documentation.
Setting up a database
Section titled “Setting up a database”It is very easy to set up a database for Hyperterse. You can use your existing database or create a new one and wire it up to Hyperterse.
-
Create database and user
Create a dedicated database and user for Hyperterse:
CREATE DATABASE myapp CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;CREATE USER 'hyperterse'@'%' IDENTIFIED BY 'secure_password';GRANT SELECT ON myapp.* TO 'hyperterse'@'%';FLUSH PRIVILEGES;Adjust the host (
%allows any host) based on your security requirements. For local-only access, use'hyperterse'@'localhost'. -
Grant permissions
Grant only the permissions needed for your use case:
-- Read-only accessGRANT SELECT ON myapp.* TO 'hyperterse'@'%';-- For write operationsGRANT INSERT, UPDATE, DELETE ON myapp.* TO 'hyperterse'@'%';-- For specific tables onlyGRANT SELECT ON myapp.users, myapp.products TO 'hyperterse'@'%'; -
Configure Hyperterse
Add the MySQL adapter to your configuration:
adapters:main_db:connector: mysqlconnection_string: 'hyperterse:secure_password@tcp(localhost:3306)/myapp?charset=utf8mb4&parseTime=true'options:max_connections: '10' -
Verify connection
Test the connection using the development server:
Terminal window hyperterse dev -f config.terseLook for a successful connection message:
INFO Connected to adapter: main_db
MySQL queries in Hyperterse support all standard SQL features. Use parameterized queries with input variables for safe execution:
queries: get-product: use: main_db description: 'Retrieve product by ID' statement: | SELECT id, name, price, description FROM products WHERE id = {{ inputs.productId }} inputs: productId: type: int description: 'Product ID'MySQL-specific features like JSON functions, window functions, and stored procedures are fully supported. Use standard MySQL syntax in your query statements.
Performance
Section titled “Performance”Hyperterse inherently does not limit any performance optimizations. You can optimize your queries and database to whatever degree MySQL allows.
Read replicas
Section titled “Read replicas”For read-heavy workloads, you can configure separate adapters for primary and replica databases:
adapters: primary: connector: mysql connection_string: '{{ env.PRIMARY_DB_URL }}' replica: connector: mysql connection_string: '{{ env.REPLICA_DB_URL }}'Route read queries to the replica and write queries to the primary.
Troubleshooting
Section titled “Troubleshooting”Access denied
Section titled “Access denied”Verify user permissions:
-- Check grantsSHOW GRANTS FOR 'hyperterse'@'%';
-- Grant if neededGRANT SELECT ON myapp.* TO 'hyperterse'@'%';FLUSH PRIVILEGES;Ensure the user exists and has the correct host permissions.
Character set issues
Section titled “Character set issues”Ensure UTF-8 support by using utf8mb4 charset:
connection_string: 'user:pass@tcp(host:3306)/db?charset=utf8mb4'Also verify the database and table character sets:
SHOW CREATE DATABASE myapp;SHOW CREATE TABLE table_name;Connection timeout
Section titled “Connection timeout”Increase timeout values in the connection string:
connection_string: 'user:pass@tcp(host:3306)/db?timeout=30s&readTimeout=30s&writeTimeout=30s'Check network connectivity and MySQL server status if timeouts persist.
Timezone issues
Section titled “Timezone issues”Set the timezone explicitly for consistent datetime handling:
connection_string: 'user:pass@tcp(host:3306)/db?parseTime=true&loc=UTC'This ensures datetime values are parsed consistently regardless of server timezone settings.