Database Requirements
MongoDB
Version: 3.6.6 or higher
Purpose: Primary database for auth, characters, inventory, game data
Required: YES
MySQL
Version: 5.7 or higher (MariaDB 10.2+)
Purpose: Persistent data, compatibility layer
Required: Highly Recommended
MongoDB Configuration
Connection String Format
MongoDB uses a URI connection string format:Basic Connection
No Authentication (Development Only):Authenticated Connection
With Username/Password (Production):Connection String Parameters
Connection String Parameters
| Parameter | Description | Example |
|---|---|---|
username | Database username | mythic_user |
password | Database password | SecurePassword123 |
host | MongoDB server address | localhost, 192.168.1.100 |
port | MongoDB port | 27017 (default) |
database | Database name | mythic |
authSource | Authentication database | admin |
Common Options
Common Options
authSource: Where user credentials are storedreplicaSet: Replica set name (for clusters)ssl: Enable SSL/TLS encryptionretryWrites: Automatic retry for write operationsMultiple options: Separate with
&Remote MongoDB
Remote MongoDB
Connecting to Remote Server:MongoDB Atlas (Cloud):Note: Atlas uses
mongodb+srv:// protocol for automatic DNS resolution.Creating MongoDB User
MongoDB Connection Troubleshooting
Connection Refused
Connection Refused
Error:
MongoNetworkError: connect ECONNREFUSED 127.0.0.1:27017Causes:- MongoDB service not running
- Wrong host/port
- Firewall blocking connection
Authentication Failed
Authentication Failed
Error:
MongoError: Authentication failedCauses:- Wrong username/password
- User doesn’t exist
- Wrong authSource
- Verify credentials are correct
- Check user exists:
db.getUsers()in mongo shell - Ensure
authSource=adminis specified - Verify user has correct roles:
Database Not Found
Database Not Found
Error: Database doesn’t existSolution: MongoDB creates databases automatically on first write. The database will be created when the framework first inserts data.Manual Creation (Optional):
Connection Timeout
Connection Timeout
Error:
MongoNetworkError: connection timeoutCauses:- Firewall blocking port
- MongoDB not bound to correct interface
- Network issues
- Check MongoDB bind address in
/etc/mongod.conf:
- Check firewall:
MySQL Configuration
Connection String Format
Mythic Framework uses oxmysql which supports standard MySQL connection strings:Basic Configuration
Local MySQL Server:charset=utf8mb4 for proper emoji and character support.
Connection String Components
Protocol
mysql:// - Standard MySQL protocolAlways use
mysql:// (not mysqli:// or others)Credentials
username:password@ - AuthenticationExample:
root:MyPassword123@Host & Port
host:port - Server addressDefault port:
3306Examples:localhost:3306192.168.1.100:3306db.example.com:3306
Database & Options
/database?options - Database name and settingsExample:
/mythic?charset=utf8mb4Common Connection Options
Connection Options Explained
Connection Options Explained
| Option | Description | Default | Recommended |
|---|---|---|---|
charset | Character encoding | utf8 | utf8mb4 |
connectionLimit | Max concurrent connections | 10 | 10-20 |
connectTimeout | Connection timeout (ms) | 10000 | 10000 |
acquireTimeout | Query timeout (ms) | 10000 | 10000 |
waitForConnections | Wait if pool is full | true | true |
queueLimit | Max queued connections | 0 | 0 (unlimited) |
debug | Debug SQL queries | false | false (prod) |
Creating MySQL Database and User
- Command Line
- phpMyAdmin
Remote MySQL Connection
Connecting to Remote Server:MySQL Connection Troubleshooting
Access Denied
Access Denied
Error:
Access denied for user 'username'@'host'Solutions:- Verify username and password are correct
- Check user exists and has correct permissions:
- Ensure password special characters are URL-encoded:
Unknown Database
Unknown Database
Error:
Unknown database 'mythic'Solution:- Database doesn’t exist, create it:
- Verify database name matches connection string exactly
Connection Timeout
Connection Timeout
Error:
Connection timeoutCauses:- MySQL not running
- Wrong host/port
- Firewall blocking
- Network issues
Too Many Connections
Too Many Connections
Error:
Too many connectionsSolution:- Increase MySQL max connections:
- Or edit
/etc/mysql/mysql.conf.d/mysqld.cnf:
- Reduce connectionLimit in oxmysql:
Testing Database Connections
Test MongoDB Connection
Test MySQL Connection
Connection String Security
Best Practices
Use Strong Passwords
- Minimum 16 characters
- Mix of uppercase, lowercase, numbers, symbols
- No dictionary words
- Use password manager to generate
Limit Access
- Create separate database users for different environments
- Grant minimum required privileges
- Use
localhostwhen possible instead of% - Enable MySQL bind-address restrictions
Production Checklist
MongoDB
✅ Authentication enabled
✅ Strong password set
✅ User has minimum required permissions
✅ Connection string includes
authSource
✅ Database firewall rules configured
✅ SSL/TLS enabled (if remote)
✅ Regular backups configuredMySQL
✅ Root login disabled for remote connections
✅ Strong password set
✅ User limited to specific database
✅
utf8mb4 charset used
✅ Connection pooling configured
✅ Firewall rules in place
✅ Regular backups configured