What are Database Hosts?
A database host is a MySQL or MariaDB server that Pterodactyl can connect to for creating databases. Fromapp/Models/DatabaseHost.php:46-49:
Database Host Properties
- Name: Friendly identifier
- Host: Hostname or IP address of the MySQL server
- Port: MySQL port (usually 3306)
- Username: MySQL user with database creation privileges
- Password: Password for the MySQL user
- Max Databases: Maximum databases this host can create (optional limit)
- Node: Optional node assignment (restricts to specific node)
Creating a Database Host
Configure Connection
Database Server Details
- Name: Descriptive name (e.g., “Primary MySQL”, “Node1-DB”)
- Host: MySQL server hostname or IP
- Port: MySQL port (default:
3306) - Username: MySQL user with GRANT privileges
- Password: MySQL user password
Set Limits (Optional)
Resource Limits
- Max Databases: Limit total databases (leave empty for unlimited)
- Linked Node: Associate with specific node (optional)
Validation Rules
Fromapp/Models/DatabaseHost.php:63-70:
Connection Testing
When creating or updating a database host, the Panel tests the connection. Fromapp/Http/Controllers/Admin/DatabaseController.php:64-78:
If the connection test fails, the database host will not be created and an error message will be displayed.
MySQL User Requirements
The MySQL user must have these privileges:Creating a MySQL User
On your MySQL server:Database Naming Convention
Pterodactyl creates databases with the pattern:- Server ID: 42
- Database name: “playerdata”
- Result:
s42_playerdata
Node Assignment
You can link a database host to a specific node:Linked to Node
- Only servers on that node can use this database host
- Useful for local MySQL servers on each node
- Better performance (reduced latency)
Not Linked (Global)
- Any server can use this database host
- Useful for centralized database servers
- Easier to manage, fewer database hosts needed
Node assignment is optional. Leave empty to make the database host available to all servers.
Viewing Database Hosts
The database hosts page displays:- Host name and connection details
- Number of databases created
- Maximum database limit (if set)
- Associated node (if linked)
Managing a Database Host
Viewing Details
Click on a database host to see:- All databases created on this host
- Associated servers
- Connection information
- Current database count vs. limit
Updating a Host
From
app/Http/Controllers/Admin/DatabaseController.php:90-111:
Deleting a Host
Database Relationships
Fromapp/Models/DatabaseHost.php:77-90:
Node Relationship
Databases Relationship
Server Database Creation
When a server owner creates a database:- They choose a database name
- System selects an available database host
- Database is created as
s{server_id}_{name} - Credentials are generated and displayed once
- Database is accessible from the server container
Remote Access Configuration
For MySQL to accept remote connections:Edit MySQL Configuration
Restart MySQL
Configure Firewall
Best Practices
- Use Strong Passwords: Generate strong passwords for MySQL users
- Limit Access: Use
node_idto restrict hosts to specific nodes - Set Max Databases: Prevent resource exhaustion with limits
- Regular Backups: Back up databases regularly
- Monitor Usage: Check database count vs. limits
- Secure Connections: Use SSL for MySQL connections if possible
- Local is Better: Use local MySQL on each node for better performance
Local vs. Remote Database Hosts
Local Database Host (Same Server as Node)
Pros:- Lower latency
- Better performance
- No network dependency
- More secure (no remote connections)
- Need MySQL on each node
- More hosts to manage
- Resources used on game server nodes
Remote Database Host (Dedicated Server)
Pros:- Centralized management
- Dedicated resources
- Easier backups
- Single point of configuration
- Network latency
- Single point of failure
- Network bandwidth usage
- Security considerations
Troubleshooting
Connection Failed
Problem: Cannot connect to MySQL server Solutions:- Verify MySQL is running
- Check hostname/IP is correct
- Ensure MySQL accepts remote connections (
bind-address) - Verify firewall allows port 3306
- Test connection manually:
Permission Denied
Problem: User doesn’t have required privileges Solutions:- Grant proper privileges (see MySQL User Requirements)
- Ensure user can connect from Panel’s IP:
- Flush privileges:
Max Databases Reached
Problem: Cannot create more databases Solutions:- Increase
max_databaseslimit - Delete unused databases
- Add another database host
Slow Database Performance
Problem: Servers experiencing database lag Solutions:- Use local database hosts on each node
- Optimize MySQL configuration
- Add more RAM to database server
- Enable query caching
- Use faster storage (SSD)
Security Considerations
Network Security
- Restrict Access: Only allow connections from node IPs
- Use Firewalls: Block port 3306 from untrusted sources
- Consider SSL: Use encrypted MySQL connections
- Private Network: Use internal network for node-to-database communication
User Privileges
- Minimal Privileges: Only grant required permissions
- Database Prefix: Always use
s%_*pattern, never*.* - No SUPER: Don’t grant SUPER or PROCESS privileges
- Regular Audits: Review user privileges periodically
Next Steps
Node Management
Learn about node configuration
Server Management
Create servers that use databases
