Oxmysql is a useful open-source FiveM resource that is already preinstalled on your FiveM game server to enable communication between the server and the database. During development, you may make changes (e.g., updating the database credentials) that require you to adjust the oxmysql connection string. Typical signs include oxmysql error messages in the server console, such as EHOSTUNREACH (database server unreachable) or the MySQL error 1045 (credentials rejected), and resources that need the database but do not start properly.
In this guide, we’ll show you how to fix database connection issues on your FiveM game server by adjusting the connection string in your server configuration file.
You don’t need a dedicated button for this: If you reset a database password using Reset password in the Databases tab of your game server, ZapX automatically adds the new password to your server.cfg when the server is set up again afterward. For the primary database of a running server, this happens immediately after the reset.
This only works as long as the connection string still contains your server’s database user. If you’ve entered your own credentials or a different database there, or the errors persist, adjust the line yourself as described below.
You can also do this in chat with the ZapX AI Agent: If oxmysql reports the error 1045 or EHOSTUNREACH, it corrects the line in your server.cfg using a card and only inserts the actual credentials after you confirm. Learn more: FiveM: Manage your server with the ZapX AI Agent.
To fix this manually, you need access to your server.cfg file, where you can manually update the connection string with the credentials from your web interface. Sign in to the txAdmin dashboard and open the CFG editor. In another tab, open the Databases tab of your game server, where you can find your current credentials.
Add the following line to your server.cfg (or replace it if it already exists) and enter your own database credentials from the web interface:
set mysql_connection_string "mysql://USER:PASSWORD@HOST:PORT/DATABASE"
You can find the values in the User, Password, Host, Port, and Database fields in the Databases tab. The port is usually 3306, but may vary.
Then save the file and restart your server.
The next time your server starts, your game server should be able to access the database without any issues, and everything should work as usual. You’ve successfully resolved your database connection issues. If you have any other questions or need help, our support team is available every day! 🙂
