# Storage and data

URL: https://greenarrowlol.github.io/TNTGamesCore/docs/configuration/storage/
Section: configuration
Description: Where player stats are stored and how to use SQLite or MySQL.

---

> For a complete page index, fetch https://greenarrowlol.github.io/TNTGamesCore/llms.txt.

Where the plugin keeps player stats and how to switch between SQLite and MySQL.

The plugin stores player stats (kills, wins, streaks, and so on) in a database. SQLite is the default and needs no setup. MySQL is optional, for sharing stats across several servers.

## Runtime drivers

The database drivers are not bundled inside the plugin jar. On the first server start, the plugin downloads the SQLite and MySQL drivers from Maven Central and loads them. This keeps the jar small and works on both Spigot and Paper.

The drivers are cached in:

```
plugins/TNTGamesCore/libs/
```

:::{warning}
The first start needs internet access to fetch the drivers. On an offline server, copy the driver jars into `plugins/TNTGamesCore/libs/` from a machine that has them, then start the server.
:::

## SQLite (default)

Nothing to configure. The plugin creates a `stats.db` file in its data folder:

```
plugins/TNTGamesCore/stats.db
```

In `config.yml`:

```yaml
database:
  enabled: false   # false = SQLite
```

Good for a single server. The file lives with the rest of your plugin data, so backing it up is just copying the folder.

## MySQL (optional)

Use MySQL to share stats across a network. Set `enabled: true` and fill in the connection details:

```yaml
database:
  enabled: true
  host: localhost
  port: 3306
  database: tntgames
  username: root
  password: changeme
```

::::{steps}
:::{step} Create the database
Make an empty database (for example `tntgames`) and a user that can access it.
:::{/step}

:::{step} Fill in config.yml
Set `enabled: true` and enter the host, port, database, username, and password.
:::{/step}

:::{step} Restart the server
Restart so the plugin connects. The console prints `Connected to MySQL database!` on success.
:::{/step}
:::{/steps}

The plugin creates its stats table automatically on first connect. You do not need to run any SQL.

:::{note}
If the plugin cannot connect, it logs the error and continues running; stats just will not save. Check the host, port, and credentials, then reload or restart.
:::

## Related

- [Configuration](/docs/configuration/configuration/): the `database` block.
- [Scoreboards and stats](/docs/features/scoreboards-and-stats/): what gets tracked.
