If you've set up a FiveM server, you've installed oxmysql โ probably because a dozen scripts demanded it. But what actually is it, and why is it so essential? Here's the plain-English explanation.
What oxmysql is
oxmysql is the bridge between your FiveM server and a database. Specifically, it lets your server's scripts read from and write to a MySQL or MariaDB database efficiently.
Think of it as the translator: your scripts speak "FiveM/Lua," your database speaks "SQL," and oxmysql sits between them handling the conversation quickly and safely.
Why servers need a database at all
Almost everything persistent on your server lives in a database:
- Player characters, money, and inventory
- Jobs and grades
- Owned vehicles and properties
- Server state that must survive restarts
Without a database, none of this would persist โ every restart would wipe everyone's progress. The database is your server's long-term memory, and oxmysql is how scripts access it.
Why oxmysql specifically
There have been other MySQL connectors for FiveM over the years (older ones like mysql-async and ghmattimysql). oxmysql, from the Overextended team, has become the standard because it's:
- Fast โ efficient query handling, important for performance
- Actively maintained โ kept current and reliable
- Well-supported โ the vast majority of modern scripts expect it
- Feature-complete โ clean API for the ways scripts need to use a database
Because so many scripts require it, oxmysql is usually one of the very first resources you install โ and it must load early, before scripts that depend on it.
How it fits into your server
The flow looks like this:
- Your database (MySQL/MariaDB) stores the data.
- oxmysql connects to it using your connection string in server.cfg.
- Your scripts ask oxmysql to fetch or save data.
- Players experience persistent characters, money, and progress.
If oxmysql can't connect to the database, that whole chain breaks โ players don't load, nothing saves. That's why oxmysql connection errors are so disruptive, and worth knowing how to fix.
Setting it up
The essentials:
- Install oxmysql as a resource.
- Set your connection string in server.cfg pointing to your database (user, password, host, port, database name).
- Ensure it loads early โ before your framework and other scripts.
- Have a database ready โ created, running, with the right credentials.
Once connected, oxmysql quietly does its job in the background, and everything that needs data just works.
Performance note
oxmysql itself is efficient, but *how scripts use it* matters. A poorly-written script that queries the database excessively can cause server-side lag that resmon won't even show. This is one reason script quality matters โ good scripts use the database sensibly.
Build on efficient scripts
At Viper Development, our scripts use oxmysql cleanly and efficiently, storing what they need without hammering your database. They document their requirements clearly, so setup is straightforward. Browse our scripts โ.