基础数据库建设,数据中心对接数据库

This commit is contained in:
超级老白兔
2025-11-07 15:40:33 +08:00
parent a997734c5c
commit 921ce713fa
6 changed files with 2197 additions and 5 deletions

View File

@@ -0,0 +1,27 @@
<?php
return [
// 默认数据库连接(可选改为 mongodb
'default' => 'mysql', // 若需全局用 MongoDB改为 'mongodb'
'connections' => [
// ... 其他连接(如 mysql保持不变
// MongoDB 官方连接配置
'mongodb' => [
'driver' => 'mongodb',
'dsn' => 'mongodb://127.0.0.1:27017', // 集群可写mongodb://node1:27017,node2:27017
'database' => 'Moncter', // 目标数据库名
'username' => 'Moncter', // 无认证则省略
'password' => '123456', // 无认证则省略
'options' => [
'replicaSet' => '', // 副本集名称(无则留空)
'ssl' => false, // 是否启用 SSL
'connectTimeoutMS' => 3000, // 连接超时
'socketTimeoutMS' => 5000, // 读写超时
// 认证相关(若 MongoDB 启用认证)
'authSource' => 'admin', // 认证数据库(默认 admin
'authMechanism' => 'SCRAM-SHA-256', // 认证机制(默认推荐)
],
],
],
];