Main Menu

MySQL Module

Started by Vortrex, January 19, 2019, 08:58:41 PM

Previous topic - Next topic


This is a simple MySQL module for those who want to use it for their server. Most of the functions have been lightly tested, but if you run into any issues please leave a reply on this topic.


Place into your server's "modules" folder and put "<module src="<I>module_folder_name/module_file_name</I>" />" into the modules section of your server XML. Be sure to include the folder your modules are stored in (it's relative to the main server directory) and do **not** include a file extension.
    <module src="modules/mod_mysql" />
For Windows, you'll need to download the libmysql.dll file that goes with your server's platform and architecture. A list of these is available on the releases page, found on the link above. This file needs to be in the main server folder, not the module folder.

For Linux, you'll need to install libmysqlclient18 ... Use your distro's package manager or download from the mysql website. Unlike Windows, you don't need any extra files in the server directory for this to work.

JavaScript Example:
let db = module.mysql.connect("localhost", "username", "password", "database", 3306);
let result = db.query("SELECT id, something FROM test");
if(result.numRows > 0) {
    let row = result.fetchRow();
    console.log("ID is " + String(row[0]));

Available Functions:
connectionHandle = module.mysql.connect(string host, string user, string password, string database, int port);
resultHandle = connectionHandle.query(string query);

void connectionHandle.close(void);
int connectionHandle.affectedRows;
int connectionHandle.insertId;
string connectionHandle.error;
int connectionHandle.errorNum;
int connectionHandle.warningCount;
string connectionHandle.escapeString(string unsafeString);
void connectionHandle.selectDatabase(string database);
void connectionHandle.changeUser(string username, string password);

int resultHandle.numRows;
int resultHandle.numFields;
table resultHandle.fetchAssoc();
array resultHandle.fetchRow();


  • Added query.fetchAssoc() function


  • Updated to work with new SDK format



  • Renamed the module to mod_mysql to support both GTAC and TRML


Instructions for x64:
  • Download mod_mysql_x64.dll from the module's github releases page.
  • Download x64 libmysql.dll from the github source (link below)
  • Place the module dll into a folder called "modules" and the libmysql.dll in the main server folder.
  • Add module to server config. It uses a relative path and exact file name, without file extension.
<module src="modules/mod_mysql_x64" />
libmysql.dll goes in main server folder, not in the modules folder