New

EmeraldHost 2.0 is here: faster, more intuitive, and made for everyone - the new panel!

Learn more
Guides
How to Set Up a Database for Your FiveM Server
FiveMFiveMSet Up Database

How to Set Up a Database for Your FiveM Server

Create a MySQL database for a FiveM server and connect it correctly

4 min read
Aug 7, 2026

Many FiveM scripts and frameworks store their data in a MySQL database. For your server to access it, you need two things: a database including its credentials, and a database resource that establishes the connection.

We recommend oxmysql. It is actively maintained and replaces the outdated resources mysql-async and ghmattimysql, whose functionality it also provides.

Create the database

  1. Create a database
    In the dashboard, go to Databases and create a new database using the plus icon. You can find the detailed instructions under Create Database.

  2. Read the credentials
    Click the eye icon next to your database. You will need these values in a moment:

    • Database Host (e.g. db1.cgn1.emeraldhost.de)
    • Database Port (default: 3306)
    • Database Username
    • Database Password
    • Database Name

Upload oxmysql

  1. Download the resource
    Download the latest release of oxmysql. Use the oxmysql.zip file and not the source code download.

  2. Extract the archive
    Extract the archive. You will get a folder named oxmysql.

  3. Stop the server
    Stop your server via the dashboard.

  4. Connect via SFTP
    Connect to your server via SFTP.

  5. Upload the folder
    Upload the oxmysql folder into the resources folder located next to your server's server.cfg.

    Setup Path
    Default (recommended) /home/container/resources
    txAdmin Recipe / Deployer /home/container/txData/<ProfileName>/resources

Enter the connection string

The connection string bundles all credentials in a single line. oxmysql reads it from the convar mysql_connection_string.

  1. Open server.cfg
    Open the server.cfg your server uses. Which one that is depends on your txAdmin setup – you can find the overview under Set Port.

  2. Set the connection string
    Add the following line and replace the placeholders with your credentials from the eye icon:

    set mysql_connection_string "mysql://USERNAME:PASSWORD@HOST:PORT/DATABASENAME"
    

    Alternatively, oxmysql also accepts the semicolon-separated format:

    set mysql_connection_string "user=USERNAME;password=PASSWORD;host=HOST;port=PORT;database=DATABASENAME"
    
  3. Only use set
    Always define the convar with set.

  4. Start oxmysql
    Below the connection string, add the start line for the resource:

    ensure oxmysql
    
  5. Start the server
    Save the server.cfg and start your server via the dashboard.

Verify the connection

After the start, open the console of your server in the dashboard. If the connection succeeded, you will find this message:

Database server connection established!

It is preceded by the version of your database server in square brackets.

If the connection fails, oxmysql prints a message in this form instead:

Unable to establish a connection to the database (ERRORCODE)!

In that case, double-check the username, password, host, port and database name via the eye icon in the dashboard.

Special characters in the password

Depending on the format you use, certain special characters are reserved or unsupported. If your database password contains one of these characters, the connection may fail:

; , / ? : @ & = + $ #

Additional convars

For troubleshooting, oxmysql offers additional convars that you also add to the server.cfg using set:

Convar Description
set mysql_debug true Prints all database queries in the console
set mysql_slow_query_warning 150 Warns if a query takes longer than the given time in milliseconds

What comes next?

Your database is connected now, but still empty. Most frameworks and scripts ship with a .sql file that creates the required tables. How to import it is explained under Import Database.

Written byEmeraldHost Team
Last updated on Aug 7, 2026 Edit on GitHub

Did this article help you?

Your feedback helps us improve our guides.

Help shape the guides

€10.00 in credit for every new guide, €5.00 for every improvement.

Contact Support

Create a support ticket and our team will get back to you as soon as possible – personal and professional.

Go to Support
1257 members online

Discord Community

Connect with other players, get quick help from the community, and stay up to date with the latest news.

Join Discord
FiveM

Ready to get started?

Rent your FiveM Server now

Join our Discord community 1257 members online right now