Many FiveM frameworks and scripts ship with an .sql file that creates all the tables they need. You load this file into your database using phpMyAdmin.
Before you start
-
Stop the server
Stop your server via the dashboard. That way no resource writes to the database while the import is running. -
Review the SQL file
Open the.sqlfile in a text editor and check whether it contains lines such asCREATE DATABASEorUSE. -
Watch out for overwritten tables
Also check the file for lines containingDROP TABLE IF EXISTS. Existing tables with the same name are deleted along with their content during the import. Back up your data beforehand.
Back up existing tables
If your database already holds data, export it before importing.
-
Open phpMyAdmin
In the dashboard, go to Databases and click the external icon next to your database, then log in. -
Select the database
Click your database in the left sidebar. -
Open the Export tab
Click Export at the top. -
Download the export
Leave the Export method on Quick - display only the minimal options and the Format on SQL. Click Export to download the file to your PC.
Import the SQL file
-
Select the database
In phpMyAdmin, click the database you want to import into in the left sidebar. -
Open the Import tab
Click Import at the top. -
Choose the file
Under File to import, use Browse your computer to select your.sqlfile. The maximum file size you are allowed to upload is shown right next to that label. -
Check the character set
Leave Character set of the file onutf-8unless your file explicitly uses a different encoding. Otherwise special characters end up broken in the database. -
Check the format
SQL has to be selected under Format. phpMyAdmin usually detects this automatically from the file extension. -
Start the import
Click Import at the bottom and wait until the page has finished loading. Do not close the browser tab in the meantime.
Check the result
-
Read the message
After a successful import, the message "Import has been successfully finished, X queries executed." appears at the top. -
Verify the tables
Click your database on the left and then on Structure. The tables from the.sqlfile should now be listed there. -
Start the server
Start your server via the dashboard and check the console for database errors.
Importing large SQL files
The upload limit on the import page is a setting of the web server phpMyAdmin runs on. You cannot change it yourself. If your file is too large or the import stops after a while, you have these options:
-
Compress the file
phpMyAdmin reads compressed files directly, and only the compressed size counts towards the upload limit. The file name has to end in.[format].[compression], for exampledatabase.sql.zip. Which compression formats are supported is shown in the note at the top of the import page. -
Allow a partial import
Under Partial import, tick Allow the interruption of an import in case the script detects it is close to the PHP timeout limit. phpMyAdmin then stops the import in a controlled way before the PHP time limit hits and continues from the stored position when you submit again. -
Split the file
Split the.sqlfile into several smaller files and import them one after another in their original order. Make sure you do not cut a statement in half.
Common errors
| Symptom | Cause and solution |
|---|---|
| Permission error (Access denied) | The file contains CREATE DATABASE or USE. Remove those lines and import into your existing database. |
| Error while creating a foreign key | Remove the tick from Enable foreign key checks under Other options and repeat the import. |
| The file cannot be selected or is too large | The upload limit is exceeded. See Importing large SQL files. |
| The import stops without a success message | Usually a timeout. See Importing large SQL files. |
| Table already exists | The table was imported before. Back it up and delete it before repeating the import. |
