[How-To] Create your standalone fivem server database (SQL Importing)

:question: What is a database?

  • A “database” is basically a file that saves data created by certain scripts or files being imported into your server that can later on be called importing all the data for a specific player or script allowing you to use anything you had prior again just from your database importing it back into the server for you to use. Once you disconnect from your server, everything you’ve done prior to joining the server will be updated in the database and stored to the recent information you had allowing you to lose no progress in your server whatsoever.

  • Now, every server comes with a pre-built database, however, it really depends on your hosting. Many servers have an option for you to have to create one manually instead of automatically. We aren’t doing manuals, we are going to set up an automatic database. If you’re wanting to set up your database manually, you’d have to purchase your hosting from a web host, such as Zap-Hosting, Rocket-Node, etc.

:question: Why do I need this for a standalone server?

  • Although your standalone server doesn’t use scripts that NEED a database, there are still scripts out there that need to be hooked to a database. For example, wanting to use gcphone for your server? You can do that, however, you need a database for it to work. There aren’t a lot of scripts that need a database, but there are some that require you having one!

:computer: Database Requirements:

  • Down below are some resources that I use to manage my own database, you don’t have to use them, however I find them easier to use than phpmyadmin.
    • Xampp download link → Here (Required for your database to run.)
    • HeidiSQL Download Link → Here (Makes importing .sql files easier.)
    • oxmysql Download Link → Here (Connects your server to the database.) (WILL NOT RUN WITH MYSQL-ASYNC)
    • mysql-async Download Link → Here (Connects your server to the database.) (WILL NOT RUN WITH OXMYSQL)
Video Instructions - Video Only.

:video_camera: Video on how to setup database:

Document Instructions - No video included.

:memo: How to create a database - FiveM Standalone Document instructions:

  1. Download and open the control panel of XAMPP.
  2. Click START for both Apache and MySQL.
  3. Click ADMIN next to the MySQL section. (This will show your database.)
  4. Copy and paste this code into your server.cfg:
oxmysql

ensure oxmysql
set mysql_connection_string “server=localhost;database=DATABASENAME;userid=root;password=”

mysql-async

ensure mysql-async
set mysql_connection_string "mysql://root@localhost/DATABASENAME?charset=utf8mb4

  1. After everything is set into the server.cfg, save the config for your server and restart it.
  2. After restarting you should see this message in your console:
oxmysql | Connection = Success

image

mysql-async | Connection = Success

4 Likes