fix(config): 更新数据库和Redis连接配置

- 修改appsettings.json中Redis连接字符串为新的服务器地址和密码
- 更新数据库连接字符串为新的服务器地址、数据库名和凭据
- 修正run.sh中数据库连接字符串环境变量的命名格式,使用小写开头
- 添加环境变量检查输出,方便确认配置是否正确加载
This commit is contained in:
jonah.fu
2025-12-06 20:35:33 +08:00
parent f9b31383da
commit e5beb6e5a2
2 changed files with 8 additions and 5 deletions
+2 -2
View File
@@ -8,7 +8,7 @@
}
},
"RedisCache": {
"ConnectionString": "server=127.0.0.1;password=;db=2",
"ConnectionString": "server=127.0.0.1:6379;password=;db=2",
"InstanceName": "COMCMS:",
"DefaultDatabase": 2,
"ConnectTimeout": 5000,
@@ -40,7 +40,7 @@
},
"connectionStrings": {
"dbconn": {
"connectionString": "Server=localhost;Port=3306;Database=comcms;Uid=root;Pwd=root;charset=utf8mb4",
"connectionString": "Server=localhost;Port=3306;Database=comcms;Uid=comcms;Pwd=root;charset=utf8mb4",
"providerName": "MySql.Data.MySqlClient"
},
"mssqlconnon": {
+6 -3
View File
@@ -8,9 +8,9 @@ else
echo "警告: .env 文件不存在,使用默认配置"
fi
# 设置数据库连接字符串(使用环境变量)
export ConnectionStrings__dbconn__ConnectionString="Server=${MYSQL_HOST:-localhost};Port=${MYSQL_PORT:-3306};Database=${MYSQL_DATABASE:-comcms};Uid=${MYSQL_USER:-root};Pwd=${MYSQL_PASSWORD:-root};charset=utf8mb4"
export ConnectionStrings__dbconn__providerName="MySql.Data.MySqlClient"
# 设置数据库连接字符串(使用环境变量,注意:冒号用双下划线替代)
export connectionStrings__dbconn__connectionString="Server=${MYSQL_HOST:-localhost};Port=${MYSQL_PORT:-3306};Database=${MYSQL_DATABASE:-comcms};Uid=${MYSQL_USER:-root};Pwd=${MYSQL_PASSWORD:-root};charset=utf8mb4"
export connectionStrings__dbconn__providerName="MySql.Data.MySqlClient"
# 设置 Redis 连接字符串
export RedisCache__ConnectionString="server=${REDIS_HOST:-127.0.0.1}:${REDIS_PORT:-6379};password=${REDIS_PASSWORD};db=${REDIS_DB:-2}"
@@ -28,6 +28,9 @@ echo "启动配置:"
echo " MySQL: ${MYSQL_HOST}:${MYSQL_PORT}/${MYSQL_DATABASE}"
echo " Redis: ${REDIS_HOST}:${REDIS_PORT}"
echo " 环境: ${ASPNETCORE_ENVIRONMENT}"
echo ""
echo "环境变量检查:"
echo " connectionStrings__dbconn__connectionString=${connectionStrings__dbconn__connectionString}"
echo "================================"
# 进入项目目录并运行