> For the complete documentation index, see [llms.txt](https://cherrycake.tin.cat/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cherrycake.tin.cat/version-1.x-beta/guide/database-guide.md).

# Database guide

## Database providers

To connect to database servers you must configure a database provider. Just like with the [Cache](/version-1.x-beta/guide/cache-guide.md) module, you can configure multiple providers to connect to multiple databases at the same time.

> Cherrycake is currently only compatible with MySQL and MariaDB servers.

Database providers are configured in the [Database configuration](/version-1.x-beta/reference/core-modules/database.md#configuration) file `Database.config.php`.For example, if you want to connect to a MySQL database server, your Cache configuration file would look like this:

```php
<?php

namespace Cherrycake;

$DatabaseConfig = [
    "providers" => [
        "main" => [
            "providerClassName" => "DatabaseProviderMysql",
            "config" => [
                "host" => "localhost",
                "user" => "user",
                "password" => "password",
                "database" => "cherrycake",
                "charset" => "utf8mb4",
                "cacheProviderName" => "engine"
            ]
        ]
    ]
];
```

> Note we called our database provider `main`&#x20;

## Modules that depend on Database

Just like Cache, some other modules use Database for many purposes, for example: The [Session](/version-1.x-beta/reference/core-modules/session.md) module uses a database connection to store information about sessions.

> That's why in the [Cherrycake Skeleton](/version-1.x-beta/guide/getting-started/skeleton.md) boilerplate you'll find the `/install` directory containing some SQL scripts to create the tables some this modules need.
