PHP 7.2.10 Laravel 5.6.39
我的服务器中有多个远程 mysql 数据库和一个 mysql 数据库。
在我的本地主机中,我能够连接到所有数据库,但在生产/测试服务器中,我无法连接到远程数据库,显示错误
Database [mysqlRemoteOne] not configured.", exception: "InvalidArgumentException
但是在本地和测试中,包含设置的 .env 文件和 config/databse.php 是相同的。测试服务器和本地服务器的权限相同。
有什么,我失踪了吗?
更新:
使用 tinker,我尝试了 mysqli 连接和 pdo 连接,我得到了
ubuntu@ip-172-31-30-158:/var/www/html/app$ php artisan tinker
Psy Shell v0.9.9 (PHP 7.2.10-0ubuntu0.18.04.1 — cli) by Justin Hileman
>>> mysqli_connect('myhost', 'user', 'password', 'db')
=> mysqli {#3054
+affected_rows: null,
+client_info: null,
+client_version: null,
+connect_errno: null,
+connect_error: null,
+errno: null,
+error: null,
+error_list: null,
+field_count: null,
+host_info: null,
+info: null,
+insert_id: null,
+server_info: null,
+server_version: null,
+stat: null,
+sqlstate: null,
+protocol_version: null,
+thread_id: null,
+warning_count: null,
}
>>> new PDO('mysql:host=myhost;dbname=db', 'user', 'password');
=> PDO {#3053
inTransaction: false,
attributes: {
CASE: NATURAL,
ERRMODE: SILENT,
AUTOCOMMIT: 1,
PERSISTENT: false,
DRIVER_NAME: "mysql",
SERVER_INFO: "Uptime: 1136758 Threads: 27 Questions: 95411 Slow queries: 0 Open s: 4155 Flush tables: 1 Open tables: 413 Queries per second avg: 0.083",
ORACLE_NULLS: NATURAL,
CLIENT_VERSION: "mysqlnd 5.0.12-dev - 20150407 - $Id: 38fea24f2847fa7534543 ae0acafe387 $",
SERVER_VERSION: "5.7.24-0ubuntu0.16.04.1",
STATEMENT_CLASS: [
"PDOStatement",
],
EMULATE_PREPARES: 1,
CONNECTION_STATUS: "myhost via TCP/IP",
DEFAULT_FETCH_MODE: BOTH,
},
}
>>>