Skip to main content
Mythic Framework uses a dual-database architecture: MongoDB for game data and authentication, and MySQL for compatibility and relational data. This guide walks you through setting up both databases.

Database Architecture Overview

MongoDB (Primary)

Stores:
  • User accounts and authentication
  • Character data
  • Inventory and items
  • Player-specific data
  • Logs and analytics
Why: Fast, flexible, document-based storage perfect for game data

MySQL (Secondary)

Stores:
  • Relational data
  • Compatibility with other resources
  • Persistent server data
  • Structured records
Why: Industry standard, excellent for structured data and compatibility
Both databases are required. Mythic Framework will not start without both MongoDB and MySQL properly configured.

MongoDB Setup

MongoDB databases (auth and fivem) are created automatically by Mythic Framework on first start. No manual database creation is required.

MongoDB Connection String

The connection string tells Mythic Framework how to connect to MongoDB. Format:
mongodb://[username:password@]host:port/[?options]
Examples:
mongodb://localhost:27017/?readPreference=primary&ssl=false
Security Warning: Never use no-authentication setup in production! Always enable authentication for production servers.
For production servers, enable authentication:
# Connect to MongoDB shell
mongo

# Switch to admin database
use admin

# Create admin user
db.createUser({
  user: "admin",
  pwd: "your_secure_admin_password",
  roles: [ { role: "root", db: "admin" } ]
})

# Create mythic user
db.createUser({
  user: "mythic",
  pwd: "your_secure_mythic_password",
  roles: [
    { role: "readWrite", db: "auth" },
    { role: "readWrite", db: "fivem" }
  ]
})

# Exit
exit
Enable authentication in MongoDB config:
Edit C:\Program Files\MongoDB\Server\6.0\bin\mongod.cfg:
security:
  authorization: enabled
Restart MongoDB service:
net stop MongoDB
net start MongoDB

Test MongoDB Connection

Verify you can connect with your configured credentials:
# Test connection
mongo "mongodb://mythic:your_secure_mythic_password@localhost:27017/auth?authSource=admin"

# Should connect successfully and show MongoDB shell
# If you get authentication error, check username/password

MySQL Setup

Create Database

Create the MySQL database for Mythic Framework:
# Connect to MySQL
mysql -u root -p
# Enter your root password when prompted
-- Create the database
CREATE DATABASE MythicFramework_345AE9 CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- Create a dedicated user (recommended)
CREATE USER 'mythic'@'localhost' IDENTIFIED BY 'your_secure_password';

-- Grant privileges
GRANT ALL PRIVILEGES ON MythicFramework_345AE9.* TO 'mythic'@'localhost';
FLUSH PRIVILEGES;

-- Verify database exists
SHOW DATABASES;
-- Should show MythicFramework_345AE9 in the list

-- Exit
EXIT;
The database name MythicFramework_345AE9 can be customized, but make sure it matches your server.cfg configuration.

MySQL Connection String

The connection string format for oxmysql: Format:
mysql://[user[:password]@]host[:port]/database[?options]
Examples:
mysql://root@localhost/MythicFramework_345AE9?charset=utf8mb4

Test MySQL Connection

Verify your connection works:
# Test connection
mysql -u mythic -p MythicFramework_345AE9

# Enter password when prompted
# Should connect successfully

# Verify database
SHOW TABLES;
# Will be empty - tables are created by framework

# Exit
EXIT;

Configure server.cfg

Now update your server.cfg with the database connection strings. Open server.cfg and find the database configuration section:
server.cfg
# MongoDB Connections
set mongodb_auth_url "mongodb://localhost:27017/?readPreference=primary&ssl=false"
set mongodb_auth_database "auth"
set mongodb_game_url "mongodb://localhost:27017/?readPreference=primary&ssl=false"
set mongodb_game_database "fivem"

# MySQL Connection
set mysql_connection_string "mysql://root:your_password@localhost/MythicFramework_345AE9?charset=utf8mb4"
Update with your actual connection strings:
# MongoDB
set mongodb_auth_url "mongodb://localhost:27017/?readPreference=primary&ssl=false"
set mongodb_auth_database "auth"
set mongodb_game_url "mongodb://localhost:27017/?readPreference=primary&ssl=false"
set mongodb_game_database "fivem"

# MySQL
set mysql_connection_string "mysql://root:your_root_password@localhost/MythicFramework_345AE9?charset=utf8mb4"
Important:
  • Replace your_password / your_secure_password with your actual passwords
  • Do NOT use root MySQL user in production
  • Keep passwords secure and never commit server.cfg to public repositories

Verify Database Configuration

Let’s verify the databases are configured correctly before starting the server.

MongoDB Verification

1

Check MongoDB is running

# Windows
net start | findstr MongoDB

# Linux
sudo systemctl status mongod
2

Check databases exist

mongo

# List databases
show dbs
# Should see 'auth' and 'fivem'
3

Test connection string

# Use the exact connection string from server.cfg
mongo "mongodb://mythic:password@localhost:27017/auth?authSource=admin"

MySQL Verification

1

Check MySQL is running

# Windows (XAMPP)
# Check XAMPP Control Panel - MySQL should be green

# Linux
sudo systemctl status mysql
# or
sudo systemctl status mariadb
2

Check database exists

mysql -u mythic -p

# List databases
SHOW DATABASES;
# Should see 'MythicFramework_345AE9'
3

Test connection string

# Extract connection details from your server.cfg string
# Example: mysql://mythic:password@localhost/MythicFramework_345AE9
mysql -h localhost -u mythic -p MythicFramework_345AE9

Database Initialization

On first server start, Mythic Framework will automatically:
  1. Connect to both databases
  2. Create required collections (MongoDB)
  3. Create required tables (MySQL)
  4. Initialize default data
  5. Create indexes for performance
You don’t need to manually create tables or collections. The framework handles this automatically on first run.

Connection Troubleshooting

Common Issues:
  1. MongoDB not running:
    # Windows
    net start MongoDB
    
    # Linux
    sudo systemctl start mongod
    
  2. Wrong connection string:
    • Check username/password
    • Verify authSource=admin if using authentication
    • Ensure database names match
  3. Authentication error:
    # Verify user exists
    mongo -u admin -p admin_password --authenticationDatabase admin
    
    use admin
    db.getUsers()
    
  4. Firewall blocking:
    # Check if MongoDB is listening
    netstat -ano | findstr :27017  # Windows
    lsof -i :27017  # Linux
    
Common Issues:
  1. MySQL not running:
    # Windows (XAMPP)
    # Start from XAMPP Control Panel
    
    # Linux
    sudo systemctl start mysql
    
  2. Wrong credentials:
    # Test credentials
    mysql -u mythic -p
    # If fails, password or username is wrong
    
  3. Database doesn’t exist:
    # Login as root and check
    mysql -u root -p
    SHOW DATABASES;
    # Create if missing
    CREATE DATABASE MythicFramework_345AE9 CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
    
  4. Host/port issues:
    # Check MySQL is listening
    netstat -ano | findstr :3306  # Windows
    lsof -i :3306  # Linux
    
  5. User doesn’t have privileges:
    # Grant privileges
    GRANT ALL PRIVILEGES ON MythicFramework_345AE9.* TO 'mythic'@'localhost';
    FLUSH PRIVILEGES;
    
If oxmysql won’t start:
  1. Check connection string format is correct
  2. Verify resource exists: resources/oxmysql/
  3. Ensure it’s started before mythic-base in resources.cfg
  4. Check console for specific error messages

Database Management Tools

MongoDB Compass

Best for:
  • Viewing character data
  • Debugging inventory issues
  • Analyzing player statistics
  • Running queries
Connect: mongodb://localhost:27017

HeidiSQL / phpMyAdmin

Best for:
  • Viewing relational data
  • Debugging SQL queries
  • Analyzing performance
  • Managing users
Connect: localhost:3306

Security Best Practices

  • Minimum 16 characters
  • Mix of uppercase, lowercase, numbers, symbols
  • Don’t use default passwords
  • Don’t reuse passwords from other services
  • Only allow localhost connections if server and database are on same machine
  • Use firewall rules to restrict database ports
  • Never expose database ports to the internet
  • Use VPN for remote database access
  • Daily automated backups
  • Test restore procedures
  • Keep backups off-site or in cloud storage
  • Backup before major updates
  • Set up monitoring for connection errors
  • Monitor disk space usage
  • Track slow queries
  • Set up alerts for unusual activity

Next Steps

Databases are configured! Now configure the rest of your server:
Before starting the server: Double-check both MongoDB and MySQL are running and connection strings in server.cfg are correct. This prevents 90% of startup issues.