# How to import SQL to database?

Some scripts come with `.sql` files. These are important - they create the necessary database tables for the resource to work properly.

Here's how to import them into your server’s database:

***

#### 🧭 **Step-by-step guide**

> In this example, we'll use [**HeidiSQL**](https://www.heidisql.com/download.php), one of the most common database tools.\
> (You can also use **phpMyAdmin** or any other database tool of your choice.)

#### 💡 Tips

> * Don't import the same file twice - if you're unsure, check if the table already exists.

***

## 1. Open your database tool

Launch **HeidiSQL**, select your saved connection (you should already have it set up), and click **Open** to connect to your MySQL server.

## 2. Select your database

On the left side, you'll see a list of databases.\
Click the one your server uses (commonly named something like `fivem`, `esx_legacy`).

## 3. Open the **Query** tab

When you go to your database, the button <kbd>**▶️ Query**</kbd> is available on the header.\
A blank editor will open where you can paste SQL code.

## 4. Upload the .sql file

Open the `.sql` file (e.g. with Notepad or any code editor), **copy everything**, and **paste it into the SQL tab in HeidiSQL**.

{% hint style="info" %}
If the resource comes with multiple files (like `items.sql`, `jobs.sql`, etc.), repeat this process for each one.
{% endhint %}

## 5. Click **Execute**

Click the **Execute SQL** button at the top (▶️ play icon), or press **F9**.\
HeidiSQL will run the code and show a success message at the bottom if everything went fine.

<figure><img src="https://3701050178-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6y0J5nnTjSyc65fbCvIU%2Fuploads%2FgQ2jOSeA52PtAVStWt11%2Fimport.gif?alt=media&#x26;token=8780ffd4-609a-40e0-aae4-408bda2f1c3e" alt=""><figcaption></figcaption></figure>

✅ **Done! Your database is now ready.**
