Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk13 min

How to Set Up a Database for Your FiveM Server

A complete FiveM database setup guide covering MariaDB versus MySQL, account creation, oxmysql installation, server.cfg connection strings, SQL imports, secure queries, backups and troubleshooting.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For an ESX, QBCore, or Qbox FiveM server, the dependable setup is MariaDB plus a dedicated database account, oxmysql, each resource’s SQL schema, and a connection string loaded before any database-dependent resource. A plain vMenu server that does not save player, economy, inventory, or housing data may not need SQL at all.

This guide takes you from an empty machine to a tested, backed-up database and shows how to diagnose the errors that usually stop FiveM servers from connecting or saving data.

As an Amazon Associate I earn from qualifying purchases.

If you still need a place to run the game server, Godlike.Host offers FiveM hosting through its own game panel, with setup in minutes after payment and SFTP/FTP access. It is not on Cfx.re’s list of authorized FiveM hosts (fivem.net, 10 Oct 2026).

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What a FiveM database setup actually includes

FiveM does not automatically create a database for a server. Frameworks and gameplay resources use a database driver to store persistent data, while the database engine stores the tables and records. A working installation has five separate pieces:

#1 Best Overall
Sale
TOZO A1 Wireless Earbuds Bluetooth 5.3 Light Weight in Ear Headphones | IPX5 Waterproof,2 Mics for AI Calls,Immersive Premium Sound Bass Headset with Charging Case,32 EQ via App Black
  • [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
  • [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
  • [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
  • [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
  • [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.
  • Database engine: MariaDB or MySQL listens on a TCP port, normally 3306.
  • Database and account: The server gets its own schema and a non-root login with access limited to that schema.
  • oxmysql: This FiveM resource translates Lua queries into database operations and provides asynchronous APIs.
  • Resource schemas: SQL files supplied by your framework and other resources create the tables they require.
  • Configuration and startup order: mysql_connection_string must be available before oxmysql, and oxmysql must start before resources that call it.

Remove any one of these and the symptoms can look similar: a resource may start but fail to save, or it may stop with an unknown-table or access-denied error.

Decide whether your server needs SQL

Framework and persistence servers

ESX, QBCore, Qbox and most role-play resource collections depend on SQL for accounts, characters, inventories, vehicles, jobs, housing, bans and other persistent state. Install the database before deploying the framework recipe, or prepare it immediately afterward and import every required schema.

Lightweight or vMenu servers

A server running only maps, vehicles, permissions and temporary session settings through vMenu may work without a database. Add SQL when a resource needs persistent player data, a web panel, logging, economy records or any other information that must survive a restart. Check each resource manifest and documentation rather than installing a database merely because the server uses FiveM.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose MariaDB or MySQL

The oxmysql documentation recommends MariaDB for compatibility and performance. MySQL can work, but MySQL 8 has differences in reserved keywords and default-value handling that can break older or loosely written resource schemas. When your resource collection was written and tested against MariaDB, using MariaDB removes an avoidable compatibility variable.

Decision point MariaDB MySQL
FiveM resource compatibility Compatibility-first choice documented for oxmysql; commonly matches existing FiveM SQL files. Generally supported, but a resource can fail when its schema relies on behavior that differs in MySQL 8.
Reserved words and defaults Usually avoids MySQL 8-specific keyword and default-value surprises. Check schemas for reserved identifiers and strict default rules, especially after a MySQL 8 upgrade.
Operational support Uses familiar SQL administration, dump and restore tools. Uses familiar SQL administration, dump and restore tools.
Hosting availability Available on most Linux distributions and many managed hosts. Available on most Linux distributions and many managed hosts.

Do not install XAMPP just to obtain a database. The oxmysql documentation specifically advises installing MariaDB directly. XAMPP adds a bundled stack you do not need for a FiveM database and can make service ownership, ports and upgrades harder to understand.

Choose where the database will run

Deployment Control Maintenance Network exposure Backup responsibility
Same machine as FiveM Full control over files, versions and firewall rules. You update MariaDB, monitor disk space and restart the service. Can remain on localhost, avoiding an internet-facing SQL port. You must create and copy backups away from the game machine.
Separate Docker or virtual machine Repeatable deployment and easier isolation. You maintain the container or guest OS, persistent volume and upgrades. Requires a private network and explicit firewall rules between FiveM and SQL. Back up the database volume or, preferably, scheduled logical dumps stored elsewhere.
Managed or hosted database Less control over engine configuration and version timing. The provider handles much of the service maintenance; you still manage users, schemas and application settings. Usually requires TLS, allowlists or a private network because the database is remote. Confirm what the provider backs up and keep independent exports.

For a single server, local MariaDB on localhost is usually the simplest arrangement. A remote database is reasonable when the game server is disposable, you operate several servers, or you need a separate failure domain. Never expose port 3306 to the whole internet when a private address or allowlist will do.

Rank #2
Sale
Smart Watch for Men Women Compatible with iPhone Samsung Android Phone 1.69 inch Full Touch Screen IP68 Waterproof Bluetooh Fitness Tracker Heart Rate/Sleep Monitor (Black)
  • 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
  • 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
  • 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
  • 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
  • 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.

Prepare the machine and credentials

  • Reserve enough disk space for the database, binary logs if enabled, and several compressed dumps.
  • Record the server’s database host and port. The default local port is 3306, but an existing service may use another port.
  • Choose a database name, such as fivem, and a long unique password for the FiveM account.
  • Keep the password out of public repositories, screenshots and paste sites. Restrict access to the configuration file that contains it.
  • Use a dedicated account for the running server. Do not put the MariaDB root password in server.cfg.

Install MariaDB

Windows

  1. Download the MariaDB installer from the official MariaDB project and run it on the machine that will host SQL.
  2. Keep the default TCP port 3306 unless another service already occupies it. If you choose a different port, record it for the connection string and firewall.
  3. Set a strong administrative password during installation and install MariaDB as a Windows service so it starts with the machine.
  4. After installation, verify that the MariaDB service is running before you configure FiveM.

Linux

  1. Install the MariaDB server and client packages from your distribution’s repository.
  2. Start and enable the MariaDB service using your distribution’s service manager.
  3. Run the supplied secure-installation routine. Remove anonymous users, disallow remote root login, remove the test database and reload privilege tables when prompted.
  4. Check that the service is listening on the intended interface and port. If FiveM and MariaDB share a host, binding SQL to localhost reduces exposure.

Package names and service commands vary by distribution, so use the commands documented for your Linux release. The important results are the same: MariaDB is running, the port is known, and root is reserved for administration rather than application queries.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Create a database and least-privilege account

Log in to MariaDB as an administrator and create an empty database using a UTF-8 collation. The following example uses the database name fivem, account fivem and a placeholder password; replace the password with your own secret.

CREATE DATABASE fivem CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'fivem'@'localhost' IDENTIFIED BY 'YOUR_LONG_RANDOM_PASSWORD';
GRANT ALL PRIVILEGES ON fivem.* TO 'fivem'@'localhost';
FLUSH PRIVILEGES;

The grant is broad inside one database but does not give the account access to other databases or administrative functions. If FiveM connects from another host, create the account for the specific private source address instead of using a wildcard host, then allow that address through the database and network firewalls. A remote account also needs the correct host name in its grant; a password alone cannot overcome a host mismatch.

Test the new credentials before touching FiveM:

mariadb -u fivem -p -h 127.0.0.1 -P 3306 fivem

At the MariaDB prompt, run SELECT 1;. A successful result proves that the account, password, host, port and database name agree. It does not prove that a framework’s tables have been imported yet.

Use a txAdmin recipe when it fits

txAdmin framework recipes can create a database and import framework SQL during deployment. This is convenient for a new ESX, QBCore or Qbox server because the recipe can place resources and schema steps in one workflow. Read the recipe’s database prompts carefully, confirm the selected database name, and inspect the resulting server.cfg. If you already have a database, do not let a recipe silently create a second one or overwrite an existing schema.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Install oxmysql in the resources directory

  1. Download the current oxmysql release from its official project source.
  2. Place the resource folder in the server’s resources directory. Keep the folder name expected by the resource, normally oxmysql.
  3. Do not rename the folder unless you also update every reference to it.
  4. Add the connection string before the resource is started, then ensure oxmysql before your framework and gameplay resources.

oxmysql is built on node-mysql2 and provides asynchronous APIs, compatibility syntax, and both URI and semicolon-separated connection strings. Its documentation is the authority for release-specific options; the configuration patterns below are the two forms supported in the supplied setup guidance.

Rank #3
New Bee Guitar Cable 10ft Electric Instrument Bass AMP Cord
  • [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
  • [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
  • [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
  • [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
  • [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by

Set mysql_connection_string in server.cfg

The convar must appear before ensure oxmysql. A URI connection string is compact and makes the character set explicit:

set mysql_connection_string "mysql://fivem:YOUR_PASSWORD@localhost:3306/fivem?charset=utf8mb4"
ensure oxmysql

The semicolon form is also supported:

set mysql_connection_string "user=fivem;password=YOUR_PASSWORD;host=localhost;port=3306;database=fivem"
ensure oxmysql

Use the host that matches your deployment. localhost may resolve through a local socket or local networking behavior, while 127.0.0.1 explicitly selects IPv4 TCP; either is fine when MariaDB is local, but the account’s host grant must match how the server connects. For a remote database, use its private address or hostname and the configured port.

Connection-string delimiters have special meaning. Avoid putting these characters directly in a password unless you understand and correctly escape the selected format: ;, ,, /, ?, :, @, &, =, +, $ and #. A password containing one of them can make a valid account appear to have the wrong password or host. Generate a secret that is easy to encode safely, or apply the correct URI encoding for the URI form.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Keep server.cfg readable only by the server operator and exclude it from public Git repositories. If you split secrets into a protected configuration file, ensure the main configuration executes that file before oxmysql.

Import every framework and resource schema

Creating an empty database is not enough. Frameworks and resources normally ship an installation .sql file containing their tables, indexes and seed data. Import the framework schema first, then import the SQL file for each resource that documents one.

Import with a graphical client

  1. Open a client such as HeidiSQL and connect with the dedicated account or an administrator account that has permission to create tables.
  2. Select the target fivem database in the left-hand tree. Selecting the wrong schema is a common cause of an apparently successful import followed by ER_NO_SUCH_TABLE.
  3. Open the framework or resource’s install SQL file and execute it.
  4. Refresh the database tree and verify that the expected tables exist. Look for the exact table names referenced by the resource.
  5. Repeat for every resource that supplies a schema, preserving the order documented by that resource.

Import from a shell

For a file named framework.sql, an administrator can use a command like:

Rank #4
BSIMB 15.6" Digital Family Calendar & Chore Chart, No Subscription Fees
  • Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
  • Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
  • All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
  • Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
  • Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.
mariadb -u fivem -p -h 127.0.0.1 -P 3306 fivem < framework.sql

On a production server, review a SQL file before executing it. It may create users, drop tables, insert default rows or assume a particular engine version. Never run an untrusted SQL file with root credentials.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Declare the dependency and query from the server

Resources that use oxmysql should load its Lua library and declare the dependency in their manifest when required by their code:

server_script '@oxmysql/lib/MySQL.lua'
dependency 'oxmysql'

Use placeholders for values rather than concatenating player input. The following examples run asynchronously and return one row or the inserted identifier:

local row = MySQL.single.await('SELECT money FROM my_accounts WHERE identifier = ?', { identifier })
local id = MySQL.insert.await('INSERT INTO my_accounts (identifier, money) VALUES (?, ?)', { identifier, 500 })

Parameterized queries protect the SQL syntax from values supplied by a player. They do not validate game logic, permissions or the type of a value, so the server must still check that a player may perform the requested action and that numbers fall within expected ranges.

Keep database code on the server

Clients should call a server event or callback. The server obtains the player’s identity, validates the request and performs the query. Do not send database credentials or unrestricted SQL to a client. A client-provided identifier, account name or amount is an input to validate, not an authority to trust.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Start resources in the correct order

A minimal ordering pattern is:

set mysql_connection_string "mysql://fivem:YOUR_PASSWORD@localhost:3306/fivem?charset=utf8mb4"
ensure oxmysql
ensure your_framework
ensure your_gameplay_resource

Place the convar before oxmysql, and oxmysql before every resource that imports its library or executes a query at startup. If a framework starts first, it may attempt a query while the driver is still unavailable. If the driver starts but the schema was not imported, the connection succeeds while table queries fail.

Restart the server and read the console from the first oxmysql message onward. A healthy startup should show a successful database connection followed by framework resources starting without repeated query errors. Test an actual save operation, reconnect, and confirm that the value persists; a connection message alone does not prove that writes work.

Back up before opening the server

A database on the same disk as the game server is not a backup if that disk fails. Schedule logical dumps, retain multiple days, and copy archives to another machine or object storage. The MariaDB and MySQL dump tools support a consistent transaction snapshot for transactional tables:

mariadb-dump --single-transaction -u fivem -p -h 127.0.0.1 -P 3306 fivem > /backup/fivem-YYYY-MM-DD.sql

mysqldump can be used where that is the installed client. Protect dump files because they contain player and server data. A practical schedule keeps daily files for several days, copies them off the FiveM host, and periodically tests a restore into a separate database. A backup that has never been restored is only an assumption.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Local, Docker and hosted setups: choose by risk

Local installation minimizes network complexity and is the easiest starting point. Docker or a virtual machine makes replacement and version pinning easier, but the database must use a persistent volume; deleting a container without its volume deletes the data. A hosted database reduces service maintenance on the game machine, yet introduces network latency, firewall rules, credentials stored outside the host and a dependency on the provider. In all three cases, scheduled off-machine dumps remain your responsibility unless you have verified an independent provider backup and restore process.

Troubleshoot connection and schema errors

Console error or symptom Likely cause Fix
ECONNREFUSED 127.0.0.1:3306 MariaDB is stopped, the host is wrong, or MariaDB listens on another port. Start the service, confirm its listening port, then make the host and port in mysql_connection_string match. Check a local firewall if the service is running.
ER_ACCESS_DENIED_ERROR Wrong username or password, a host mismatch in the account grant, or insufficient privileges. Log in with the same host, port and credentials from a MariaDB client. Inspect the account’s grants and recreate or alter the account for the actual source host. Confirm the password was not split by a connection-string delimiter.
ER_BAD_DB_ERROR or unknown database The database was never created or its name differs from the connection string. Run SHOW DATABASES; as an administrator, create the intended database if absent, and make the configured name identical, including capitalization where the operating system makes it significant.
ER_NO_SUCH_TABLE The framework or resource SQL file was not imported into the selected database. Find the resource’s install SQL, select the configured database, execute it, refresh the table list and restart the resource.
Names or emoji appear garbled The connection or tables use a character set that cannot represent the data. Use utf8mb4 for the database and tables, and add ?charset=utf8mb4 to the URI connection string. Review existing table collations before converting data.
Framework starts but saves fail oxmysql started after the framework, the account lacks write privileges, or the query is failing on a missing column/table. Move ensure oxmysql above the framework, test an insert using the dedicated account, and read the first SQL error rather than only the final save warning.
Queries work manually but not in FiveM FiveM is reading a different configuration file, using a different resource folder name, or connecting with a different host string. Print or inspect the active startup configuration, verify the exact resource name and dependency, and compare the server’s connection details with the successful command-line test.
Only one resource fails after an update That resource’s schema was not upgraded, or a new version expects a column or index that is absent. Read the resource’s migration notes, back up first, and apply its update SQL to the same database. Do not drop production tables to silence an error.

Production checks before inviting players

  • Least privilege: The runtime account is not root and cannot administer unrelated databases.
  • Correct encoding: New databases and the connection use utf8mb4.
  • Startup order: The convar precedes oxmysql, and oxmysql precedes every dependent resource.
  • Schema completeness: Every framework and resource SQL file has been imported into the configured database.
  • Write test: Create or change a test record, restart the server, reconnect and verify persistence.
  • Network controls: A remote database accepts connections only from the FiveM host or private network.
  • Secret handling: Passwords are absent from public repositories and readable only by operators.
  • Recovery: A recent dump exists off the game host and a restore has been tested.
  • Maintenance: Monitor disk usage, database logs and failed queries, and schedule engine and resource updates during a maintenance window.

Final setup checklist

  1. Install MariaDB directly rather than adding an unnecessary bundled stack.
  2. Create the fivem database with utf8mb4 and a dedicated account.
  3. Install oxmysql in the resources directory.
  4. Set mysql_connection_string before ensure oxmysql.
  5. Ensure oxmysql before the framework and gameplay resources.
  6. Import the framework schema and every resource-specific SQL file.
  7. Use server-side, parameterized queries and validate all client input.
  8. Perform a real save-and-restart test.
  9. Schedule off-machine dumps and test restoring one.

That sequence gives a framework-based FiveM server a compatible database engine, a controlled account, the correct driver, complete schemas and a recoverable data store. If your server is only a non-persistent vMenu installation, you can stop after confirming that none of its resources require SQL.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.