|
@@ -81,6 +81,35 @@ class ServerConfigLogic extends BaseLogic |
|
@@ -81,6 +81,35 @@ class ServerConfigLogic extends BaseLogic |
|
81
|
}
|
81
|
}
|
|
82
|
|
82
|
|
|
83
|
/**
|
83
|
/**
|
|
|
|
84
|
+ * @remark :验证数据库
|
|
|
|
85
|
+ * @name :mysqlConfig
|
|
|
|
86
|
+ * @author :lyh
|
|
|
|
87
|
+ * @method :post
|
|
|
|
88
|
+ * @time :2023/8/28 11:57
|
|
|
|
89
|
+ */
|
|
|
|
90
|
+ public function mysqlConfig($data){
|
|
|
|
91
|
+ // 构建数据库配置数组
|
|
|
|
92
|
+ $dbConfig = [
|
|
|
|
93
|
+ 'driver' => 'mysql', // 数据库类型
|
|
|
|
94
|
+ 'host' => $data['host'], // 数据库主机
|
|
|
|
95
|
+ 'database' => $data['host'], // 数据库名
|
|
|
|
96
|
+ 'username' => $data['username'], // 数据库用户名
|
|
|
|
97
|
+ 'password' => $data['password'], // 数据库密码
|
|
|
|
98
|
+ ];
|
|
|
|
99
|
+ // 临时设置数据库配置
|
|
|
|
100
|
+ config(['database.connections.temp' => $dbConfig]);
|
|
|
|
101
|
+ try {
|
|
|
|
102
|
+ // 使用数据库配置信息尝试建立数据库连接
|
|
|
|
103
|
+ DB::connection()->getPdo();
|
|
|
|
104
|
+ // 如果连接成功,表示账号、密码和主机信息正确
|
|
|
|
105
|
+ echo "Database connection successful!";
|
|
|
|
106
|
+ } catch (\Exception $e) {
|
|
|
|
107
|
+ // 连接失败,输出错误信息
|
|
|
|
108
|
+ echo "Database connection failed: " . $e->getMessage();
|
|
|
|
109
|
+ }
|
|
|
|
110
|
+ }
|
|
|
|
111
|
+
|
|
|
|
112
|
+ /**
|
|
84
|
* @remark :删除记录
|
113
|
* @remark :删除记录
|
|
85
|
* @name :delServiceConfig
|
114
|
* @name :delServiceConfig
|
|
86
|
* @author :lyh
|
115
|
* @author :lyh
|