fix(docs): fix config toml
This commit is contained in:
@@ -92,22 +92,15 @@ cargo run
|
||||
|
||||
#### 方式二:使用 MySQL/PostgreSQL
|
||||
|
||||
**步骤 1**:复制对应的配置文件
|
||||
**步骤 1**:修改配置文件
|
||||
|
||||
```bash
|
||||
# 使用 MySQL
|
||||
cp config/development.mysql.toml config/local.toml
|
||||
|
||||
# 或使用 PostgreSQL
|
||||
cp config/development.postgresql.toml config/local.toml
|
||||
```
|
||||
|
||||
**步骤 2**:修改配置文件
|
||||
|
||||
编辑 `config/local.toml`,修改数据库连接信息:
|
||||
编辑 `config/development.toml`,修改数据库类型和连接信息:
|
||||
|
||||
```toml
|
||||
[database]
|
||||
# 修改数据库类型:mysql, postgresql 或 sqlite
|
||||
type = "mysql" # 或 "postgresql"
|
||||
|
||||
# MySQL 配置
|
||||
host = "localhost"
|
||||
port = 3306
|
||||
@@ -116,6 +109,7 @@ password = "your-password"
|
||||
database = "web_template_dev"
|
||||
|
||||
# 或 PostgreSQL 配置
|
||||
# type = "postgresql"
|
||||
# host = "localhost"
|
||||
# port = 5432
|
||||
# user = "postgres"
|
||||
@@ -123,11 +117,10 @@ database = "web_template_dev"
|
||||
# database = "web_template_dev"
|
||||
```
|
||||
|
||||
**步骤 3**:运行项目
|
||||
**步骤 2**:运行项目
|
||||
|
||||
```bash
|
||||
# 使用指定配置文件运行
|
||||
cargo run -- -c config/local.toml
|
||||
cargo run
|
||||
```
|
||||
|
||||
#### 方式三:通过环境变量覆盖(适用于 Docker/Kubernetes)
|
||||
@@ -171,11 +164,16 @@ cargo run
|
||||
|
||||
**选项 1**:修改配置文件
|
||||
|
||||
```bash
|
||||
# 复制 MySQL 配置模板
|
||||
cp config/development.mysql.toml config/local.toml
|
||||
编辑 `config/development.toml`,设置数据库类型为 `mysql` 并修改连接信息:
|
||||
|
||||
# 编辑 config/local.toml,修改数据库连接信息
|
||||
```toml
|
||||
[database]
|
||||
type = "mysql"
|
||||
host = "localhost"
|
||||
port = 3306
|
||||
user = "root"
|
||||
password = "your-password"
|
||||
database = "web_template_dev"
|
||||
```
|
||||
|
||||
**选项 2**:使用环境变量
|
||||
@@ -198,7 +196,21 @@ cargo run
|
||||
|
||||
**适用场景**:需要高级数据库功能的应用
|
||||
|
||||
**配置方法**:与 MySQL 类似,使用 `config/development.postgresql.toml` 或环境变量
|
||||
**配置方法**:
|
||||
|
||||
编辑 `config/development.toml`,设置数据库类型为 `postgresql` 并修改连接信息:
|
||||
|
||||
```toml
|
||||
[database]
|
||||
type = "postgresql"
|
||||
host = "localhost"
|
||||
port = 5432
|
||||
user = "postgres"
|
||||
password = "your-password"
|
||||
database = "web_template_dev"
|
||||
```
|
||||
|
||||
或使用环境变量(格式与 MySQL 相同)。
|
||||
|
||||
### 认证配置
|
||||
|
||||
@@ -243,7 +255,8 @@ cargo run
|
||||
|
||||
**使用指定配置文件**:
|
||||
```bash
|
||||
cargo run -- -c config/development.mysql.toml
|
||||
# 修改 config/development.toml 后运行
|
||||
cargo run
|
||||
```
|
||||
|
||||
**使用环境变量**:
|
||||
|
||||
Reference in New Issue
Block a user