Database
Install MariaDB and create the login your Cobalt server uses.
Cobalt stores players, characters, inventories, vehicles and everything else in MariaDB, through cobalt_mysql.
Version
Use MariaDB 12.3, the current long-term support release. Anything from 10.11 up works. Cobalt is developed and run on 12.x.
Install on Windows
- Download the MSI package for 12.3 from mariadb.org/download.
- Run it. On the settings page:
- Set a strong root password and write it down.
- Leave Enable access from remote machines for 'root' user unticked.
- Keep Install as service ticked, with the port at 3306.
- Finish the installer. MariaDB now starts with Windows.
The installer also adds HeidiSQL, which you can use to browse the database.
Create a login for the server
The txAdmin recipe connects with the login you give it and creates the database if it doesn't exist. You have two options.
Use root. Enter root and its password in txAdmin, and txAdmin creates the database. This is fine when MariaDB runs on the same machine and only listens on 127.0.0.1.
Use a dedicated user. Open the MySQL Client from the Start menu, sign in as root, and run:
CREATE DATABASE cobalt CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'cobalt'@'localhost' IDENTIFIED BY 'choose-a-strong-password';
GRANT ALL PRIVILEGES ON cobalt.* TO 'cobalt'@'localhost';
FLUSH PRIVILEGES;Then enter cobalt, its password and the database name cobalt in txAdmin. The user can't create databases, which is why you create it here first; txAdmin finds it and uses it.
You don't import any SQL. On its first start, each Cobalt resource creates the tables it's missing.
The connection string
The server reads its login from mysql_connection_string in server.cfg. The recipe writes it for you. For a manual install, it looks like this:
set mysql_connection_string "mysql://cobalt:choose-a-strong-password@127.0.0.1:3306/cobalt?charset=utf8mb4"Use 127.0.0.1 rather than localhost. On Windows, localhost can resolve to IPv6 first and slow down every connection.
When an update changes a table
Cobalt is pre-release, and an update can change a table's layout. Cobalt only creates missing tables on start and never changes existing ones, so a changed table shows up as Unknown column errors in the console.
Back up before every update:
mariadb-dump -u root -p cobalt > cobalt.sqlWhen we can, the update ships a migration SQL file that alters the tables in place and keeps your data. Run it against your database before you start the server, and read the release notes for its name.
Some breaking updates can't be migrated. For those, the fix is to wipe the database and let Cobalt create the tables again on the next start:
DROP DATABASE cobalt;
CREATE DATABASE cobalt CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;A wipe loses every character, item and vehicle.