# Database configuration (PostgreSQL)

To configure PostgreSQL for Bekane, you first need to create a dedicated database and user account.

### Access the PostgreSQL Shell

Switch to the PostgreSQL system user and open the PostgreSQL interactive shell:

```bash
su postgres   # Run as root
psql
```

### Create the Database and Dedicated User

Create a database for Bekane and a dedicated user with a secure password:

```sql
CREATE DATABASE bekane;
CREATE USER bekaneuser WITH ENCRYPTED PASSWORD 'asecurepassword';
GRANT ALL PRIVILEGES ON DATABASE bekane TO bekaneuser;
```

{% hint style="info" %}
Replace `asecurepassword` with a strong and secure password.
{% endhint %}

### Connect to the Bekane Database

Switch to the newly created database:

```sql
\c bekane
```

### Configure Schema Permissions

Grant the required permissions on the `public` schema and ensure future tables and sequences remain accessible to the Bekane user:

```sql
GRANT ALL ON SCHEMA public TO bekaneuser;
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO bekaneuser;
GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO bekaneuser;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON TABLES TO bekaneuser;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON SEQUENCES TO bekaneuser;
```

These permissions ensure that Bekane can:

* Create and modify tables
* Manage database sequences
* Access future objects created in the schema

### Test the Database Connection

Exit the PostgreSQL shell and test the connection using the dedicated user:

```bash
psql -U bekaneuser -W -h localhost bekane
```

If the connection succeeds, PostgreSQL is correctly configured for Bekane.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://documentation.bekane.org/aministrator-docs/server-setup/database-configuration-postgresql.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
