Introduction

Installation

Install gmsv_mongo on your Garry's Mod server

Installation

Installing gmsv_mongo is straightforward. Follow these steps to get the MongoDB driver running on your Garry's Mod server.

Prerequisites

Before installing gmsv_mongo, ensure you have:

  • A Garry's Mod server (dedicated or local)
  • MongoDB server (local or remote) - Download MongoDB
  • Basic knowledge of Lua programming
  • Access to your server's file system

Step 1: Determine Your Platform

First, you need to identify which binary you need for your server. Run this command in your GMod server console:

lua_run print(jit.os, jit.arch)

This will output something like:

  • Linux x86 - Linux 32-bit
  • Linux x64 - Linux 64-bit
  • Windows x86 - Windows 32-bit
  • Windows x64 - Windows 64-bit

Most modern GMod servers run on Linux x86 (32-bit) by default, even on 64-bit operating systems. Make sure to download the correct binary for your server, not your OS.

Step 2: Download the Binary

Download the appropriate binary for your platform from the GitHub Releases page:

PlatformBinary NameWhen to Use
Linux 32-bitgmsv_mongo_linux.dllDefault GMod branch on Linux
Linux 64-bitgmsv_mongo_linux64.dllx86-64 GMod branch on Linux
Windows 32-bitgmsv_mongo_win32.dllDefault GMod branch on Windows
Windows 64-bitgmsv_mongo_win64.dllx86-64 GMod branch on Windows

The .dll extension is used for all platforms in GMod's binary module system, even on Linux. Don't try to rename it to .so!

Step 3: Install the Binary

  1. Navigate to your Garry's Mod server directory
  2. Open the garrysmod/lua/bin/ folder
    • If the bin folder doesn't exist, create it
  3. Place the downloaded binary file in this folder
# Example directory structure
garrysmod/
├── lua/
   ├── bin/
   └── gmsv_mongo_linux.dll  # Your binary here
   ├── autorun/
   └── ...
├── addons/
└── ...

Step 4: Verify Installation

Create a test script to verify the installation. Create garrysmod/lua/autorun/server/test_mongo.lua:

test_mongo.lua
-- Test MongoDB connection
require("mongo")

print("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")
print("gmsv_mongo Module Loaded!")
print("Version:", MongoDB.Version())
print("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")

-- Test connection (update with your MongoDB details)
timer.Simple(1, function()
    local success, client = pcall(function()
        return MongoDB.Client("mongodb://localhost:27017")
    end)
    
    if success and client then
        print("✓ MongoDB connection successful!")
        
        -- List databases
        local dbs = client:ListDatabases()
        if dbs then
            print("Available databases:", table.concat(dbs, ", "))
        end
    else
        print("✗ MongoDB connection failed!")
        print("Make sure MongoDB is running and accessible")
    end
end)

Step 5: Start Your Server

Start or restart your Garry's Mod server. Check the console output for the test messages.

If you see:

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
gmsv_mongo Module Loaded!
Version: 2.0.0
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✓ MongoDB connection successful!

Congratulations! gmsv_mongo is installed and working.

Troubleshooting

Module Not Loading

Solution:

  • Verify the binary is in garrysmod/lua/bin/
  • Ensure you downloaded the correct platform binary
  • Check file permissions (should be readable by the server process)
  • Restart your server completely

Connection Failed

Solution:

  • Verify MongoDB is running: systemctl status mongod (Linux) or check Services (Windows)
  • Check the connection string is correct
  • Ensure MongoDB is accessible on the network (check firewall)
  • Test connection with mongosh or MongoDB Compass
  • Check MongoDB logs for errors

Wrong Binary Platform

Solution:

  • Double-check your platform with lua_run print(jit.os, jit.arch)
  • Download the matching binary
  • Most servers use 32-bit binaries even on 64-bit OS