Overview

The Server uses SQL Server (version 2012 or later) through ODBC. You need 2 databases:

Database Sample name Contains Table creation script
Main database MuOnline Accounts, characters, items, guilds, Events... MuOnline.sql
Log database LogMuOnline Transaction logs, item drops, trading... LogMuOnline.sql

You can name the databases whatever you like, as long as you enter the correct names in the .conf files (see the connection string section below). The game website uses an additional separate database; see the Game website setup section.

[NEEDS CHECKING: where the 3 script files (CreateDatabase.sql, MuOnline.sql, LogMuOnline.sql) are located in the package delivered to customers; the Server package currently only contains update scripts in Update\...\Server\SQL]

Step 1: Install SQL Server

  1. Install SQL Server 2012 or later (the Express edition was used during development). Select the Database Engine service.
  2. At the Authentication step choose Mixed Mode (SQL Server + Windows) and set a password for the sa account. If you only use Windows login, leave the account empty in the connection string (see below).
  3. Open SQL Server Configuration Manager → SQL Server Network Configuration → Protocols → enable TCP/IP, default port 1433. Restart the SQL Server service.
  4. Also install SQL Server Management Studio (SSMS) to run the scripts.
Only open port 1433 to the Server machine itself (or to IPs of trusted machines). Do not expose 1433 to the Internet.

Step 2: Install the ODBC Driver

Install the Microsoft ODBC Driver for SQL Server (64-bit version). The Server programs automatically detect available drivers in the following order and use the first one found:

  1. ODBC Driver 18 for SQL Server
  2. ODBC Driver 17 for SQL Server
  3. ODBC Driver 13 for SQL Server
  4. SQL Server Native Client 11.0

With the "ODBC Driver" family, the programs connect with Encrypt=no;TrustServerCertificate=yes, so there is no need to install an SSL certificate for SQL Server.

Step 3: Create the databases

  1. Open SSMS and log in to the SQL Server you just installed.
  2. Open the CreateDatabase.sql file. At the top of the file there are 3 variables:
    DECLARE @MainDb sysname = N'MuOnline'         -- main database
    DECLARE @LogDb  sysname = N'LogMuOnline'      -- log database
    DECLARE @DropExistingDatabases INT = 0        -- 1 = DELETE existing databases with the same name (ALL DATA LOST)
    Change the names if you want, keep @DropExistingDatabases = 0, and click Execute. The script only creates missing databases, does not specify file paths, and does not force a collation (it follows the default settings of the SQL Server you installed).
  3. In SSMS select the MuOnline database, open MuOnline.sql, and Execute.
  4. Select the LogMuOnline database, open LogMuOnline.sql, and Execute.
Each script drops and recreates all of its tables. Re-running a script on a database that contains data will cause data loss. The scripts have safeguards: they will not run on master, model, msdb, tempdb, and they report an error if you mistakenly run the main database script on the log database (or vice versa), in which case nothing is changed.

Database version

The srv_config table has a db_version row (this release uses 1.0.0). On startup, ConnectServer / LoginServer / ServerLink / GameServer check this value; if it differs from the version the program requires, it will not start and writes an error log stating clearly which SQL file you need to run. When updating versions, always run the SQL files that come with the Update (see Version update).

Connection strings in .conf files

Every database connection is written as a single line with 5 parts, separated by ;:

AccountDB = "127.0.0.1;1433;sa;your_password;MuOnline"
Part Meaning
1. Server 127.0.0.1 (same machine), ., localhost, the IP of the SQL Server machine, or MACHINENAME\INSTANCE_NAME if you installed a named instance.
2. Port Default 1433. Empty or 0 = default port.
3. Account For example sa. Empty = log in with the Windows account running the program.
4. Password The password of the account above. Passwords containing the characters ;, {, } or = are handled correctly.
5. Database name The name of the main database or the log database.

The database connection keys are located in the following files and must be edited consistently:

File Key Points to database
1.ConnectServer\connectserver.conf AccountDB Main
2.LoginServer\loginserver.conf AccountDB Main
3.ServerLink\serverlink.conf GameDB Main
Data\game_common.conf (all GameServers) GameDB, AccountDB Main
Data\game_common.conf LogDB Log

Each key also has .Threads (number of background connections, 1 - 32) and .QueryThreads (number of direct query connections). The sample values 1 and 2 are enough for a small machine; if LoginServer has many players logging in at the same time, increase AccountDB.QueryThreads to 2 - 4.

You should create a dedicated SQL account (not sa) with db_owner permission on exactly these 2 databases, then enter it in the .conf files. The password is stored in plain text in the .conf files, so only allow administrators to access the Server folder.

Testing the connection

  1. Log in to SSMS again with the exact account and password written in the .conf to make sure you can sign in.
  2. Turn on ConnectServer in START. The log should contain a line like Database AccountDB version 1.0.0 OK (the program logs are written in English; GameServer also writes lines for GameDB and LogDB). If you see "this server needs version ..." instead, the script was not run correctly; see Troubleshooting.