How to Import a .sql File for a FiveM Script
Find where a FiveM script's .sql file comes from, then import it with the mysql client, HeidiSQL, phpMyAdmin or your host panel.
Short answer
Take the .sql file from the resource's download or docs, create an empty database, and import the file into it with a command-line client or a database tool. Do this before you start the resource, so the tables exist when the script first runs. The command is mysql -u USER -p DATABASE < file.sql, where USER and DATABASE are your own values.
Where the .sql file comes from
The file is not made by the script's own code. It comes with the resource or framework that needs it. A forum reply in an ox_inventory support thread says that "ox_inventory doesn't come with any sql files at all. You get the sql files from whatever framework your running." (cfx.re forum thread)
So check these places, in order:
- The resource's download, often a
.sqlfile in the folder or in asqlsubfolder. - The resource's install docs, which usually name the file and say when to import it.
- The framework's documentation, if the script depends on a framework such as ESX or QBCore.
Before you start
Create an empty database for your server first. The import command does not create the database for you. Note its name and the user that will own it. Keep the password out of screenshots, chat logs and public files.
Import the framework's SQL first, then the SQL for each script that needs tables. Start the server only after the imports finish.
Three ways to import
1. Command line with the mysql client
Run this in a terminal on the machine that has the database client installed:
mysql -u USER -p DATABASE < file.sql
Replace USER with your database user, DATABASE with the database name, and file.sql with the path to the file. The -p flag makes the client ask for the password, so you do not type it in the command. The MariaDB client takes the same redirect form, mariadb DATABASE < file.sql, and its docs show it for running SQL statements from a script file (MariaDB client docs).
2. A GUI tool: HeidiSQL or phpMyAdmin
In HeidiSQL, select the target database, then choose File and then "Run SQL file". Pick the file, set its encoding, and click OK (HeidiSQL help).
In phpMyAdmin, select the database in the left panel, open the Import tab, and choose the file. phpMyAdmin's FAQ says that upload size is limited by PHP settings such as upload_max_filesize and post_max_size. For a large file, split it, or run source file.sql; inside the MySQL shell if you have shell access (phpMyAdmin FAQ).
3. The hosting panel
Many game hosts give you a database manager inside their control panel, often phpMyAdmin. Open it, select the database, and import the file the same way as above. The steps differ by host, so follow your host's own guide for the exact menu names.
Check that the tables exist
After the import, list the tables in the database. In the mysql client, run:
SHOW TABLES;
Look for the table names the resource's docs list. If they are missing, the import went to a different database, or it stopped early. Start the resource only after the tables you expect are present.
If the import fails
- Table already exists. The file was imported before, or another install created the same table. Do not drop tables blindly, because that deletes their data. Either use a fresh database or check the existing tables first. Back up the database before you drop anything.
- Unknown database or access denied. The database name or user in the command is wrong, or the user has no rights on that database. Check both values, and confirm the user can see the database.
- Wrong database. The tables went into a database the server does not use. Compare the database name with the one in your server's connection string. If the resource still cannot connect, see the oxmysql connection-refused guide.
- Garbled characters or errors on special text. The file encoding does not match the import setting. In HeidiSQL, set the encoding in the Run SQL file dialog. Use the same encoding as the file.
Frequently asked questions
Do I import the SQL again after I update a script?
Read the update notes first. Some updates add tables, and others change nothing. Running the whole file again often fails with "table already exists", so import only the new statements, or use a fresh database and back up the old one first.
Which SQL file do I use with ox_inventory?
ox_inventory does not ship a .sql file, according to the forum reply linked above. The tables you need come from the framework you run, so import that framework's SQL.
Do I need to create the database before importing?
Yes. The command loads the file into a database that already exists. Create it first, give the user access to it, and then run the import.
Sources
- cfx.re forum: ox_inventory "unable to execute a query" thread
- MariaDB command-line client documentation
- HeidiSQL help
- phpMyAdmin FAQ
- IONOS: how to import a MySQL/MariaDB database
Last checked: 29 November 2026. Commands, menu names and tool behavior were checked against the sources above on that date. Script and framework file layouts change between releases, so always confirm the file and its import steps in the docs for your own resource.
FiveM.tools was founded with sponsorship from Nyru.