Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion docs/containers.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,10 @@ driver = "mysql"
path = "mysql://db_user:db_user_secret_password@mysql:3306/torrust_tracker"
```

Important: if the MySQL password contains reserved URL characters (for example `+`, `/`, `@`, or `:`), it must be percent-encoded in the DSN password component. For example, if the raw password is `a+b/c`, use `a%2Bb%2Fc` in the DSN.

When generating secrets automatically, prefer URL-safe passwords (`A-Z`, `a-z`, `0-9`, `-`, `_`) to avoid DSN parsing issues.

### Build and Run:

```sh
Expand Down Expand Up @@ -292,7 +296,7 @@ These are some useful commands for MySQL.
Open a shell in the MySQL container using docker or docker-compose.

```s
docker exec -it torrust-mysql-1 /bin/bash
docker exec -it torrust-mysql-1 /bin/bash
docker compose exec mysql /bin/bash
```

Expand Down
4 changes: 3 additions & 1 deletion packages/configuration/src/v2_0_0/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ pub struct Database {
/// Database connection string. The format depends on the database driver.
/// For `sqlite3`, the format is `path/to/database.db`, for example:
/// `./storage/tracker/lib/database/sqlite3.db`.
/// For `Mysql`, the format is `mysql://db_user:db_user_password:port/db_name`, for
/// For `mysql`, the format is `mysql://db_user:db_user_password@host:port/db_name`, for
/// example: `mysql://root:password@localhost:3306/torrust`.
/// If the password contains reserved URL characters (for example `+` or `/`),
/// percent-encode it in the URL.
#[serde(default = "Database::default_path")]
pub path: String,
}
Expand Down
3 changes: 3 additions & 0 deletions share/default/config/tracker.container.mysql.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ private = false

[core.database]
driver = "mysql"
# If the MySQL password includes reserved URL characters (for example + or /),
# percent-encode it in the DSN password component.
# Example: password a+b/c -> a%2Bb%2Fc
path = "mysql://db_user:db_user_secret_password@mysql:3306/torrust_tracker"

# Uncomment to enable services
Expand Down