Link Your Database to FiveM

Learn how to connect your MariaDB database to your FiveM server and ensure proper SQL communication for your scripts and framework.

Locate your server.cfg

Navigate to the root directory of your FiveM server and locate the server.cfg file.

This configuration file controls the main settings for your server — including database integration.


Define the Database Connection String

Inside server.cfg, add the following line:

set mysql_connection_string "server=127.0.0.1;database=ambitions_framework;user=root;password=your_password"

Replace the values with your actual MariaDB credentials:

  • server=127.0.0.1 → Use 127.0.0.1 if your database is hosted on the same machine as the FiveM server. Otherwise, enter the correct IP address.

  • database=ambitions_framework → Use the name of the database you created via HeidiSQL.

  • user=root → Replace root with the proper database user if you created a specific one.

  • password=your_password → Enter the correct password for the specified user.

Keep credentials secure, especially in production.


Restart Your FiveM Server

Once the connection string has been added:

  1. Save the server.cfg file.

  2. Restart your FiveM server.

If the connection is valid, your server will automatically establish communication with the database upon boot.


Verify the Connection

  • Check your console output when the server starts — it should log successful SQL connection.

  • If you’re using a framework like Ambitions, verify it loads without SQL-related errors.

  • You can also manually insert a test row into your database and validate retrieval from a script.


circle-info

Note on Production Environments

In production setups, avoid using the root user and use a limited-permission user instead. Also ensure your remote MySQL access is restricted and firewall-protected.

Once connected, your FiveM server is ready to store data and interact with MariaDB-driven logic from your scripts and framework modules.

Last updated