Connect Your Database
Learn how to securely connect DB24x7 to your database. We support all major database systems with multiple connection methods.
Connection Methods
Direct Connection
Connect directly using a connection string
RECOMMENDEDSSH Tunnel
Connect through an SSH tunnel for added security
Cloud Provider IAM
Use cloud provider credentials (AWS IAM, GCP Service Account)
Security Best Practices
- • Always use read-only database users
- • Enable SSL/TLS encryption for connections
- • Use strong, unique passwords
- • Restrict access by IP address when possible
- • Regularly rotate credentials
Connection String Formats
Use these connection string formats for each database type. Replace placeholders with your actual credentials.
PostgreSQL
Connection String
postgresql://username:password@hostname:5432/database?sslmode=requireCreate Read-Only User
-- Create read-only user CREATE USER db24x7_monitor WITH PASSWORD 'secure_password'; GRANT CONNECT ON DATABASE your_database TO db24x7_monitor; GRANT USAGE ON SCHEMA public TO db24x7_monitor; GRANT SELECT ON ALL TABLES IN SCHEMA public TO db24x7_monitor; GRANT SELECT ON ALL SEQUENCES IN SCHEMA public TO db24x7_monitor; -- For future tables ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO db24x7_monitor;
MySQL
Connection String
mysql://username:password@hostname:3306/database?ssl=trueCreate Read-Only User
-- Create read-only user CREATE USER 'db24x7_monitor'@'%' IDENTIFIED BY 'secure_password'; GRANT SELECT, SHOW DATABASES ON *.* TO 'db24x7_monitor'@'%'; GRANT PROCESS, REPLICATION CLIENT ON *.* TO 'db24x7_monitor'@'%'; FLUSH PRIVILEGES;
SQL Server
Connection String
sqlserver://username:password@hostname:1433?database=dbname&encrypt=trueCreate Read-Only User
-- Create read-only user CREATE LOGIN db24x7_monitor WITH PASSWORD = 'Secure_Password123!'; USE your_database; CREATE USER db24x7_monitor FOR LOGIN db24x7_monitor; ALTER ROLE db_datareader ADD MEMBER db24x7_monitor; GRANT VIEW SERVER STATE TO db24x7_monitor; GRANT VIEW DATABASE STATE TO db24x7_monitor;
MongoDB
Connection String
mongodb://username:password@hostname:27017/database?authSource=admin&ssl=trueCreate Read-Only User
// Create read-only user
use admin;
db.createUser({
user: "db24x7_monitor",
pwd: "secure_password",
roles: [
{ role: "read", db: "your_database" },
{ role: "clusterMonitor", db: "admin" }
]
});Oracle
Connection String
oracle://username:password@hostname:1521/servicenameCreate Read-Only User
-- Create read-only user CREATE USER db24x7_monitor IDENTIFIED BY "Secure_Password123"; GRANT CONNECT TO db24x7_monitor; GRANT SELECT ANY DICTIONARY TO db24x7_monitor; GRANT SELECT ON V_$SESSION TO db24x7_monitor; GRANT SELECT ON V_$SQL TO db24x7_monitor; GRANT SELECT ON DBA_TABLES TO db24x7_monitor;
ClickHouse
Connection String
clickhouse://username:password@hostname:9000/database?secure=trueCreate Read-Only User
-- Create read-only user CREATE USER db24x7_monitor IDENTIFIED WITH sha256_password BY 'secure_password'; GRANT SELECT ON your_database.* TO db24x7_monitor; GRANT SHOW ON your_database.* TO db24x7_monitor;
Cloud-Managed Databases
DB24x7 works seamlessly with cloud-managed database services. Here are provider-specific instructions.
Amazon RDS / Aurora
1. Enable Enhanced Monitoring in RDS console
2. Modify security group to allow inbound connections from DB24x7 IPs
3. Use the RDS endpoint as hostname in connection string
postgresql://user:pass@your-db.abc123.us-east-1.rds.amazonaws.com:5432/dbnameGoogle Cloud SQL
1. Add DB24x7 IP addresses to authorized networks
2. Enable Cloud SQL Admin API
3. Use the public IP or private IP (if using VPC peering)
mysql://user:pass@34.123.45.67:3306/dbname?ssl=trueAzure SQL Database
1. Add DB24x7 IPs to firewall rules in Azure Portal
2. Ensure "Allow Azure services" is enabled if using agent
3. Use fully qualified server name
sqlserver://user:pass@yourserver.database.windows.net:1433?database=dbname&encrypt=trueMongoDB Atlas
1. Add DB24x7 IPs to IP Access List
2. Create a database user with "readAnyDatabase" role
3. Use the connection string from Atlas dashboard
mongodb+srv://user:pass@cluster0.abc123.mongodb.net/dbname?retryWrites=true&w=majorityTesting Your Connection
Before Connecting to DB24x7
Test your connection locally to ensure credentials and network access are correct:
PostgreSQL
psql "postgresql://user:pass@host:5432/db"MySQL
mysql -h host -P 3306 -u user -p dbMongoDB
mongosh "mongodb://user:pass@host:27017/db"Connection Test in DB24x7
When adding a database in DB24x7, use the "Test Connection" button before saving. This verifies that DB24x7 can reach your database and authenticate successfully.
Troubleshooting Connection Issues
Common connection issues and how to resolve them.
Connection Timeout
Common Causes
- •Firewall blocking connection
- •Database server not accessible from DB24x7
- •Incorrect hostname or port
Solutions
- Check firewall rules and whitelist DB24x7 IP addresses
- Verify database is listening on the correct network interface
- Test connection using telnet or nc: telnet hostname port
Authentication Failed
Common Causes
- •Incorrect username or password
- •User doesn't have necessary permissions
- •Host-based authentication restrictions
Solutions
- Verify credentials are correct
- Ensure user has at least SELECT permissions
- Check pg_hba.conf (PostgreSQL) or authentication settings
SSL/TLS Errors
Common Causes
- •Certificate validation failures
- •Mismatched SSL/TLS versions
- •Self-signed certificates
Solutions
- Use sslmode=require instead of verify-full for testing
- Ensure database supports TLS 1.2+
- Provide custom CA certificate if using self-signed certs
Permission Denied
Common Causes
- •User lacks required permissions
- •Schema or database access not granted
- •Missing system table access
Solutions
- Grant SELECT on all required tables and views
- Grant access to performance schema/system views
- Review user permissions with SHOW GRANTS or equivalent
Still Having Issues?
If you're still experiencing connection problems, our support team is here to help.
Contact Support