Skip to main content

Connect MySQL Database to FiveM

Learn how to connect a MySQL database to your FiveM server using OxMySQL. This guide covers creating the database in Pterodactyl, configuring the connection string in server.cfg, and handling special characters in passwords.

1. Access the ElypseCloud panel

Log in to your ElypseCloud account via the client area and open the management panel for your FiveM server.

2. Access the Databases section

In the server administration interface, go to the Databases section.

3. Create a database

Create a new database.

Connect from

Make sure to leave the "Connect from" field empty or set it to % to allow connections from any IP address.

(Optional) Import your SQL

After creating the database, you can import your SQL file via PhpMyAdmin if needed.

File size limit

The maximum file size for SQL import is 2 MB.

If your file is larger, use an external tool such as HeidiSQL or MySQL Workbench.

4. Choose the connection format

There are two connection formats. Choose the one that matches your needs.

"Classic" format (key=value)

Use this format if: your password does NOT contain the following characters: ; ? : = #

set mysql_connection_string "server=DB_HOST;user=DB_USER;database=DB_NAME;password=DB_PASSWORD"

Example:

set mysql_connection_string "server=51.75.30.126;user=u123_utilisateur;database=s123_fivem;password=MyPassword"

Meaning of each element:

  • DB_HOST → the database IP (ex: 51.75.30.126)
  • DB_USER → the username (ex: u123_utilisateur)
  • DB_NAME → the database name (ex: s123_fivem)
  • DB_PASSWORD → the database password
Special characters with OxMySQL

If your password contains the characters ; ? : = #, this format will not work. Use the DSN URL format below or rotate your password in your panel.

"URL DSN" format

Use this format if: your password contains special characters.

set mysql_connection_string "mysql://DB_USER:DB_PASSWORD@DB_HOST:DB_PORT/DB_NAME"

Example:

set mysql_connection_string "mysql://u123_utilisateur:MyPassword@51.75.30.126:3306/s123_fivem"

Meaning of each element:

  • DB_USER → the username (ex: u123_utilisateur)
  • DB_PASSWORD → the database password
  • DB_HOST → the IP address (ex: 51.75.30.126)
  • DB_PORT → the port (usually 3306)
  • DB_NAME → the database name (ex: s123_fivem)
Special characters in the password

If your password contains special characters such as @, #, $, %, &, etc., you have two options:

Option 1 (Recommended): rotate your password in the panel to generate a password without special characters.

Option 2 (Advanced): percent-encode the special characters in the URL:

  • @ becomes %40
  • # becomes %23
  • $ becomes %24
  • % becomes %25
  • & becomes %26

Example: if your password is Pass@123#, use Pass%40123%23 in the connection string.

5. Configure your server.cfg file

  1. Open server.cfg in your server file manager
  2. Add the connection line you selected (classic format or URL DSN)
  3. Replace all placeholders (DB_USER, DB_PASSWORD, etc.) with your real credentials
  4. Save the file
With TxAdmin

If you use TxAdmin, edit the file through the TxAdmin interface to avoid file conflicts.

6. Restart your server

Restart your FiveM server to apply the changes.


🎉 Congratulations

Your database is now linked to your FiveM server!

Need help?

If you encounter any issues, open a ticket on our Discord.