> ## Documentation Index
> Fetch the complete documentation index at: https://help.freakhosting.com/llms.txt
> Use this file to discover all available pages before exploring further.

# How to Connect Your MySQL Database in FiveM

> Master persistent data storage. Learn how to link your FiveM framework (QB-Core/ESX) to a high-performance MySQL database for player data and inventories.

## Managing Persistent Community Data

In the modern FiveM ecosystem, a strong database is the fundamental foundation of any persistent community. Whether you are hosting a complex economy-based Roleplay (RP) server or a competitive racing hub, your database is responsible for storing every critical data point - including character bank balances, vehicle ownership, housing coordinates, and inventory states. Establishing a secure and optimized connection string is the most important technical step in ensuring your server's long-term stability and performance.

<CardGroup cols={2}>
  <Card title="Difficulty" icon="gauge-low">
    Intermediate
  </Card>

  <Card title="Time" icon="clock">
    7 Minutes
  </Card>
</CardGroup>

***

## Step 1: Initialize Your Infrastructure

Every FREAKHOSTING plan includes a dedicated MySQL environment. Follow these steps to generate your unique credentials.

<Steps>
  <Step title="Access Database Management">
    Log in to the [Game Panel](https://games.freakhosting.com) and navigate to the **Databases** tab in the sidebar.
  </Step>

  <Step title="Generate New Registry">
    Click the **New Database** button. Provide a descriptive name (e.g., `freak_rp_live`) and set the "Connection From" field to `%` to allow internal node synchronization.
  </Step>

  <Step title="Retrieve Authorization Details">
    Once created, click the **Eye icon** or the menu dots to reveal your **Endpoint (Host)**, **Username**, **Password**, and **Database Name**. Copy these details precisely.
  </Step>
</Steps>

***

## Step 2: Configuring the Connection String

Open your `server.cfg` file. Depending on your chosen database wrapper, the syntax required for the connection string will vary.

<Tabs>
  <Tab title="Modern (oxmysql)">
    This is the current industry recommendation for high-performance servers.

    ```cfg theme={null}
    set mysql_connection_string "mysql://USER:PASSWORD@ENDPOINT:3306/DATABASE_NAME?waitForConnections=true&charset=utf8mb4"
    ```
  </Tab>

  <Tab title="Legacy (mysql-async)">
    Required for older community scripts that have not yet transitioned to modern standards.

    ```cfg theme={null}
    set mysql_connection_string "server=ENDPOINT;database=DATABASE_NAME;userid=USER;password=PASSWORD"
    ```
  </Tab>
</Tabs>

***

<Important>
  ### Technical Loading Priority

  FiveM initializes resources sequentially. Your database wrapper (e.g., **oxmysql**) **MUST** be initialized before any script that attempts to query or save data. In your `server.cfg`, ensure the initialization command `ensure oxmysql` appears at the very beginning of your resource list, immediately following the default system requirements.
</Important>

***

<Note>
  ### Need Extra Help?

  If you encounter any issues, our support team is ready to assist:

  * **Live Chat:** Quick assistance via our website.
  * **Support Ticket:** [Open a Ticket](https://freakhosting.com/clientarea/submitticket.php)
  * **Discord:** [Join our Community](https://discord.gg/freakhosting)
  * **Email:** [support@freakhosting.com](mailto:support@freakhosting.com)
</Note>

<Tip>
  ### Save on Your Hosting

  Ready to get a new server? Use code **KB20** at checkout for **20% off** your first month!
</Tip>

***

<div align="center">
  **Last Updated:** January 2026 | **FiveM:** Database connected.
</div>
