Creating a Connection
This guide walks you through creating a database connection in DataRecs.
Prerequisites
Section titled “Prerequisites”- A DataRecs account with access to a workspace.
- Network connectivity from DataRecs to your database (your admin may need to allowlist DataRecs egress IPs).
- Database credentials with read access.
Create the connection
Section titled “Create the connection”- Navigate to Connections in the sidebar.
- Click New Connection.
- Select your database type (e.g. MySQL, PostgreSQL, Oracle, DB2).
- Fill in the connection details:
- Name — a friendly label for this connection.
- Host — the database hostname or IP.
- Port — the database port.
- Database — the schema/database name.
- Username and Password.
- Click Test Connection to validate.
- Once the test passes, click Save.
datarecs connection create \ --name "production-mysql" \ --type mysql \ --host db.example.com \ --port 3306 \ --database mydb \ --username readonly_userYou will be prompted for the password. The CLI encrypts it before transmission.
resource "datarecs_connection" "prod_mysql" { workspace_id = datarecs_workspace.main.id name = "production-mysql" type = "mysql" host = "db.example.com" port = 3306 database = "mydb" username = "readonly_user" password = var.db_password}tofu plantofu applycurl -X POST https://api.datarecs.com/v1/connections \ -H "Authorization: Bearer $DATARECS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "name": "production-mysql", "type": "mysql", "host": "db.example.com", "port": 3306, "database": "mydb", "username": "readonly_user", "password": "REDACTED" }'What happens behind the scenes
Section titled “What happens behind the scenes”- DataRecs validates connectivity by opening a test connection to your database.
- Credentials are envelope-encrypted and stored in HashiCorp Vault.
- A Kubernetes Network Policy is created to allow egress traffic to your database host.
Troubleshooting
Section titled “Troubleshooting”| Issue | Solution |
|---|---|
| Connection timeout | Verify your database is reachable from DataRecs. Check firewall rules and allowlisted IPs. |
| Authentication failed | Double-check username and password. Ensure the user has SELECT privileges. |
| SSL required | Add --ssl flag (CLI) or set "ssl": true in the connection config. |