config: use direct MySQL connection string

This commit is contained in:
fuenmao
2026-09-21 14:20:36 +08:00
parent 8553df5dd2
commit b1a311cf84
5 changed files with 5 additions and 23 deletions
+1 -2
View File
@@ -11,8 +11,7 @@ logs/
*.user
*.suo
# Local secrets and runtime files
**/Configuration/Database.local.json
# Runtime files
**/wwwroot/upload/
*.db
*.db-shm
@@ -1,10 +0,0 @@
{
"DbConnection": {
"ConnectionConfigs": [
{
"DbType": "MySqlConnector",
"ConnectionString": "Server=127.0.0.1;Port=3306;Database=evergreen_health;User ID=root;Password=CHANGE_ME;CharSet=utf8mb4;SslMode=None;Pooling=true;Connection Timeout=30"
}
]
}
}
-6
View File
@@ -10,12 +10,6 @@ public class WebComponent : IWebComponent
{
public void Load(WebApplicationBuilder builder, ComponentContext componentContext)
{
// 本机数据库配置。该文件已加入 .gitignore,仅用于保存真实连接信息。
builder.Configuration.AddJsonFile(
"Configuration/Database.local.json",
optional: true,
reloadOnChange: true);
// 设置日志过滤
builder.Logging.AddFilter((provider, category, logLevel) =>
{
@@ -10,7 +10,7 @@
//"ConfigId": "1300000000001", // 默认库标识-禁止修改
"DbType": "MySqlConnector", // MySql、SqlServer、Sqlite、Oracle、PostgreSQL、Dm、Kdbndp、Oscar、MySqlConnector、Access、OpenGauss、QuestDB、HG、ClickHouse、GBase、Odbc、Custom
"DbNickName": "系统库",
"ConnectionString": "Server=127.0.0.1;Port=3306;Database=evergreen_health;Uid=root;Pwd=CHANGE_ME;SslMode=None;AllowLoadLocalInfile=true;AllowUserVariables=true;CharSet=utf8mb4;", // 本地开发MySQL:请替换Uid和Pwd
"ConnectionString": "AllowLoadLocalInfile=true;Server=116.168.197.2;User ID=admin;Password=so^867z$4S;Port=16306;Database=evergreen_health;CharSet=utf8mb4;Pooling=true;SslMode=None;min pool size=1;Connection Timeout=30;Pooling=false", // 本地开发MySQL:请替换Uid和Pwd
//"ConnectionString": "PORT=5432;DATABASE=xxx;HOST=localhost;PASSWORD=xxx;USER ID=xxx", // PostgreSQL
//"ConnectionString": "Server=localhost;Database=xxx;Uid=xxx;Pwd=xxx;SslMode=None;AllowLoadLocalInfile=true;AllowUserVariables=true;", // MySql,
//"ConnectionString": "User Id=xxx; Password=xxx; Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=ORCL)))", // Oracle
+3 -4
View File
@@ -4,10 +4,9 @@
## 本地启动
1. 复制 `Evergreen.Health.Api/Configuration/Database.local.example.json` 为 `Database.local.json`。
2. 修改 `Database.local.json` 中的 MySQL 连接字符串。该文件已被 Git 忽略,不会提交密码。
3. 执行 `dotnet restore Evergreen.Health.sln`。
4. 执行 `dotnet run --project Evergreen.Health.Api/Evergreen.Health.Api.csproj`。
1. 修改 `Evergreen.Health.Application/Configuration/Database.json` 中的 MySQL 连接字符串。
2. 执行 `dotnet restore Evergreen.Health.sln`。
3. 执行 `dotnet run --project Evergreen.Health.Api/Evergreen.Health.Api.csproj`。
## 健康业务接口