Before starter-core can keep history and labels, it needs a MariaDB or MySQL database. This tutorial installs the server for your distribution, creates the schema, and points the Core at it with gsettings.

You should already have the packages installed — see Install from source if you have not done that yet.

1. Install the server

Pick your distribution family. After the server is running, continue with the SQL steps below (they are the same everywhere).

Debian, Ubuntu, and free-software derivatives such as Trisquel and PureOS (apt).

sudo apt update
sudo apt install --no-install-recommends mariadb-server
sudo systemctl enable --now mariadb
sudo systemctl status mariadb --no-pager

default-mysql-server also works if you prefer MySQL packaging. Root SQL shell:

sudo mysql

2. Create a user and the STARTER schema

In the root SQL shell from your distro tab, create the database and a dedicated user. Replace the password with a secret of your own:

CREATE DATABASE STARTER
  CHARACTER SET utf8mb4
  COLLATE utf8mb4_unicode_ci;

CREATE USER 'starter'@'localhost' IDENTIFIED BY 'change-me';
GRANT ALL PRIVILEGES ON STARTER.* TO 'starter'@'localhost';
FLUSH PRIVILEGES;
EXIT;

If the Core will connect from another host, create a user for that host (or '%' with care) and open the server accordingly. For a first local install, localhost is enough.

3. Create the tables

The Core expects at least three tables: labels, history, and stats. Apply them as the starter user (or as root into STARTER):

mysql -u starter -p STARTER <<'SQL'
CREATE TABLE labels (
    id INT NOT NULL AUTO_INCREMENT,
    name VARCHAR(100) NOT NULL UNIQUE,
    description TEXT NOT NULL,
    type VARCHAR(50) NOT NULL,
    unit INT NOT NULL,
    min DOUBLE NOT NULL,
    max DOUBLE NOT NULL,
    step DOUBLE NOT NULL,
    PRIMARY KEY (id),
    INDEX idx_labels_type (type)
);

CREATE TABLE history (
    id BIGINT NOT NULL AUTO_INCREMENT,
    timestamp DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    source VARCHAR(100) NOT NULL,
    label_id INT NOT NULL,
    value DOUBLE NOT NULL,
    flags BIGINT UNSIGNED NOT NULL,
    PRIMARY KEY (id),
    FOREIGN KEY (label_id) REFERENCES labels(id),
    INDEX idx_label_time (label_id, timestamp),
    INDEX idx_history_source (source)
);

CREATE TABLE stats (
    id                INTEGER PRIMARY KEY AUTO_INCREMENT,
    service_name      VARCHAR(100) NOT NULL UNIQUE,
    updated_at        TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,

    vmsize_min        REAL NOT NULL,
    vmsize_max        REAL NOT NULL,
    vmsize_last       REAL NOT NULL,

    vmrss_min         REAL NOT NULL,
    vmrss_max         REAL NOT NULL,
    vmrss_last        REAL NOT NULL,

    vmswap_min        REAL NOT NULL,
    vmswap_max        REAL NOT NULL,
    vmswap_last       REAL NOT NULL,

    io_read_min       REAL NOT NULL,
    io_read_max       REAL NOT NULL,
    io_read_last      REAL NOT NULL,

    io_write_min      REAL NOT NULL,
    io_write_max      REAL NOT NULL,
    io_write_last     REAL NOT NULL,

    cpu_min           REAL NOT NULL,
    cpu_max           REAL NOT NULL,
    cpu_last          REAL NOT NULL,

    icswitch_min      REAL NOT NULL,
    icswitch_max      REAL NOT NULL,
    icswitch_last     REAL NOT NULL,

    priority_min      REAL NOT NULL,
    priority_max      REAL NOT NULL,
    priority_last     REAL NOT NULL,

    threads_min       REAL NOT NULL,
    threads_max       REAL NOT NULL,
    threads_last      REAL NOT NULL,
    INDEX idx_service_name (service_name)
);
SQL

Check:

mysql -u starter -p -e 'SHOW TABLES FROM STARTER;'

You should see history, labels, and stats.

4. Point starter-core at the database

The Core reads connection settings from GSettings under org.starter.core (command-line --db-* flags override them when you need a one-off).

gsettings set org.starter.core db-host '127.0.0.1'
gsettings set org.starter.core db-port 3306
gsettings set org.starter.core db-user 'starter'
gsettings set org.starter.core db-pass 'change-me'
gsettings set org.starter.core db-name 'STARTER'

Use the same password you set in SQL. Optional but recommended for a real plant:

# Peer auth (empty = open; set a shared secret when you harden the plant)
gsettings set org.starter.core auth-token ''
# Debug channel secret (independent of peer auth)
gsettings set org.starter.core debug-auth-token ''

Verify the keys:

gsettings list-recursively org.starter.core | grep '^org.starter.core db-'

If gsettings cannot find the schema, ensure starter-core was installed and schemas were compiled (a normal make install of core runs glib-compile-schemas).

5. Quick connectivity check

With starter-db from addons (if you installed it):

starter-db --host 127.0.0.1 --port 3306 \
  --user starter --password 'change-me' --database STARTER \
  -c 'SHOW TABLES;'

Or with the MySQL client:

mysql -h 127.0.0.1 -P 3306 -u starter -p STARTER -e 'SELECT COUNT(*) FROM labels;'

When this works, the Core can use the database. Next: enable and start starter-core, then attach peers — see Documentation and further tutorials.

6. Troubleshooting

Symptom What to check
Access denied for user Password, host (localhost vs 127.0.0.1), and GRANT on STARTER.*.
Unknown database 'STARTER' Run CREATE DATABASE again; check db-name in gsettings.
Core starts but no history User needs write rights; confirm tables exist; check Core logs.
gsettings schema missing Reinstall core; run sudo glib-compile-schemas /usr/local/share/glib-2.0/schemas (or your prefix).
Guix: service not found Add (service mysql-service-type) and guix system reconfigure; then herd start mysql.

Ask on the forum if you get stuck, with the SQL or Core log excerpt (no passwords).