Skip to main content
Mythic Framework uses a dual-database architecture: two MongoDB databases (Auth and Game) plus MySQL via oxmysql.

Database Requirements

MongoDB

Version: 3.6.6 or higher Purpose: Primary database — two separate databases for auth and game data Required: YES

MySQL

Version: 5.7 or higher (MariaDB 10.2+) Purpose: Inventory persistence, compatibility layer Required: YES

MongoDB Configuration

Mythic requires 4 separate convars for two MongoDB databases:
ConvarPurposeExample Value
mongodb_auth_urlAuth DB connection stringmongodb://localhost:27017/...
mongodb_auth_databaseAuth DB nameauth
mongodb_game_urlGame DB connection stringmongodb://localhost:27017/...
mongodb_game_databaseGame DB namefivem
Two separate MongoDB databases are required. The auth database stores accounts and bans. The fivem database stores characters, vehicles, inventory, properties, and all game data.

Basic Connection (Development)

# server.cfg — MongoDB Auth Database
set mongodb_auth_url "mongodb://localhost:27017/?readPreference=primary&ssl=false"
set mongodb_auth_database "auth"

# server.cfg — MongoDB Game Database
set mongodb_game_url "mongodb://localhost:27017/?readPreference=primary&ssl=false"
set mongodb_game_database "fivem"

Authenticated Connection (Production)

# server.cfg — MongoDB Auth Database
set mongodb_auth_url "mongodb://mythic_user:SecurePassword123@localhost:27017/?authSource=admin&readPreference=primary"
set mongodb_auth_database "auth"

# server.cfg — MongoDB Game Database
set mongodb_game_url "mongodb://mythic_user:SecurePassword123@localhost:27017/?authSource=admin&readPreference=primary"
set mongodb_game_database "fivem"
Both databases can share the same MongoDB server and credentials — they are just different database names within the same MongoDB instance.
ParameterDescriptionExample
usernameDatabase usernamemythic_user
passwordDatabase passwordSecurePassword123
hostMongoDB server addresslocalhost, 192.168.1.100
portMongoDB port27017 (default)
authSourceAuthentication databaseadmin
readPreferenceRead preferenceprimary
sslEnable SSL/TLStrue or false
Remote Server:
set mongodb_auth_url "mongodb://mythic_user:password@192.168.1.100:27017/?authSource=admin"
set mongodb_game_url "mongodb://mythic_user:password@192.168.1.100:27017/?authSource=admin"
MongoDB Atlas (Cloud):
set mongodb_auth_url "mongodb+srv://username:password@cluster0.xxxxx.mongodb.net/?retryWrites=true&w=majority"
set mongodb_game_url "mongodb+srv://username:password@cluster0.xxxxx.mongodb.net/?retryWrites=true&w=majority"
Atlas uses mongodb+srv:// protocol for automatic DNS resolution. The database name is set separately via the mongodb_auth_database and mongodb_game_database convars.

What Each Database Stores

Database name: auth
CollectionData
accountsPlayer accounts, identifiers, roles
bansBan records

Creating MongoDB User

1

Connect to MongoDB

mongo
2

Switch to Admin Database

use admin
3

Create User with Access to Both Databases

db.createUser({
  user: "mythic_user",
  pwd: "SecurePassword123",
  roles: [
    { role: "readWrite", db: "auth" },
    { role: "dbAdmin", db: "auth" },
    { role: "readWrite", db: "fivem" },
    { role: "dbAdmin", db: "fivem" }
  ]
})
4

Verify Connection

mongo "mongodb://mythic_user:SecurePassword123@localhost:27017/?authSource=admin"

MongoDB Troubleshooting

Error: MongoNetworkError: connect ECONNREFUSED 127.0.0.1:27017Solutions:
# Check if MongoDB is running (Linux)
sudo systemctl status mongod
sudo systemctl start mongod

# Check if MongoDB is running (Windows)
Get-Service MongoDB

# Verify port is listening
netstat -an | grep 27017
Error: MongoError: Authentication failedSolutions:
  • Verify credentials are correct
  • Ensure authSource=admin is in the connection string
  • Verify user has roles for both auth and fivem databases:
use admin
db.getUser("mythic_user")
MongoDB creates databases automatically on first write. The auth and fivem databases will be created when the framework first starts and inserts data.

MySQL Configuration

Connection String

Mythic uses oxmysql with a standard MySQL connection string:
# server.cfg
set mysql_connection_string "mysql://root@localhost/MythicFramework?charset=utf8mb4"
set mysql_slow_query_warning 300
The default database name is MythicFramework. Always use charset=utf8mb4 for proper character support.

Connection String Components

mysql://username:password@host:port/database?options
ComponentDescriptionExample
usernameMySQL userroot, mythic_user
passwordMySQL password (optional for root@localhost)SecurePassword123
hostMySQL serverlocalhost, 192.168.1.100
portMySQL port (default 3306, can be omitted)3306
databaseDatabase nameMythicFramework

Common Configurations

# Local development (root, no password)
set mysql_connection_string "mysql://root@localhost/MythicFramework?charset=utf8mb4"

# Local with password
set mysql_connection_string "mysql://mythic_user:password@localhost/MythicFramework?charset=utf8mb4"

# Remote server
set mysql_connection_string "mysql://mythic_user:password@192.168.1.100:3306/MythicFramework?charset=utf8mb4"

Slow Query Warning

oxmysql can warn you about slow queries:
# Warn for queries taking longer than 300ms
set mysql_slow_query_warning 300

Creating MySQL Database and User

-- Login to MySQL
-- mysql -u root -p

-- Create database
CREATE DATABASE MythicFramework CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- Create user (production)
CREATE USER 'mythic_user'@'localhost' IDENTIFIED BY 'SecurePassword123';

-- Grant permissions
GRANT ALL PRIVILEGES ON MythicFramework.* TO 'mythic_user'@'localhost';

-- Apply changes
FLUSH PRIVILEGES;

MySQL Troubleshooting

Error: Access denied for user 'username'@'host'
  • Verify username and password
  • Check user exists: SELECT User, Host FROM mysql.user;
  • URL-encode special characters in passwords:
# Password: My$ecure@Pass → My%24ecure%40Pass
mysql://user:My%24ecure%40Pass@localhost/MythicFramework
Error: Unknown database 'MythicFramework'Create it:
CREATE DATABASE MythicFramework CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
Increase MySQL max connections:
SET GLOBAL max_connections = 200;
Or reduce oxmysql connection limit in the connection string:
?charset=utf8mb4&connectionLimit=5

Complete server.cfg Example

# === MONGODB (Auth Database — accounts, bans) ===
set mongodb_auth_url "mongodb://localhost:27017/?readPreference=primary&ssl=false"
set mongodb_auth_database "auth"

# === MONGODB (Game Database — characters, vehicles, inventory, etc.) ===
set mongodb_game_url "mongodb://localhost:27017/?readPreference=primary&ssl=false"
set mongodb_game_database "fivem"

# === MYSQL (oxmysql — inventory persistence) ===
set mysql_connection_string "mysql://root@localhost/MythicFramework?charset=utf8mb4"
set mysql_slow_query_warning 300

Production Checklist

1

MongoDB

  • Authentication enabled with strong password
  • User has readWrite + dbAdmin roles on both auth and fivem
  • Connection strings include authSource=admin
  • Firewall configured (port 27017)
  • Regular backups configured
2

MySQL

  • Strong password set (not root with no password)
  • User limited to MythicFramework database
  • utf8mb4 charset used
  • Firewall configured (port 3306)
  • Regular backups configured
3

server.cfg

  • All 4 MongoDB convars set
  • MySQL connection string configured
  • Credentials not committed to git

Next Steps

Server Configuration

Complete server.cfg settings guide

Database Architecture

Learn how Mythic uses databases internally

Resource Management

Configure resource load order

Troubleshooting

Common setup issues and fixes