fix(docs): fix config toml

This commit is contained in:
2026-02-13 16:06:56 +08:00
parent 7ef61145f6
commit fb30d5da1a
4 changed files with 57 additions and 43 deletions

View File

@@ -37,13 +37,21 @@ cargo run
**使用 MySQL/PostgreSQL**
复制对应的配置文件并修改
使用环境变量配置或创建本地配置文件:
**方式一:使用环境变量(推荐)**
```bash
# 使用 MySQL
cp config/development.mysql.toml config/local.toml
DATABASE_TYPE=mysql DATABASE_HOST=localhost DATABASE_PORT=3306 DATABASE_USER=root DATABASE_PASSWORD=your-password DATABASE_DATABASE=web_template_dev cargo run
# 或使用 PostgreSQL
cp config/development.postgresql.toml config/local.toml
DATABASE_TYPE=postgresql DATABASE_HOST=localhost DATABASE_PORT=5432 DATABASE_USER=postgres DATABASE_PASSWORD=your-password DATABASE_DATABASE=web_template_dev cargo run
```
**方式二:创建本地配置文件**
```bash
# 复制开发环境配置
cp config/development.toml config/local.toml
# 编辑 config/local.toml修改数据库连接信息
# 然后运行
@@ -98,18 +106,14 @@ curl -X POST http://localhost:3000/auth/register \
使用 `config/` 目录下的配置文件:
```bash
# SQLite默认
# SQLite默认,修改 config/development.toml 中的 database.type 为 "sqlite"
cargo run
# MySQL
cp config/development.mysql.toml config/local.toml
# 编辑 config/local.toml
cargo run -- -c config/local.toml
# MySQL(修改 config/development.toml 中的 database.type 为 "mysql"
cargo run
# PostgreSQL
cp config/development.postgresql.toml config/local.toml
# 编辑 config/local.toml
cargo run -- -c config/local.toml
# PostgreSQL(修改 config/development.toml 中的 database.type 为 "postgresql"
cargo run
```
**生产环境**