我想连接到远程数据库托管在cpanel做一些opreations一样
$remoteMaxTimestamp = DB::connection('remote')->table($table)->max('updated_at');
但是当我尝试用postman测试它时,它需要很多时间“超过120秒的最大执行时间”我不知道为什么,我在cpanel上找到了远程MySQL部分,但我不知道它是否相关。
这是我的数据库配置
在.env文件中
DB_HOST_remote=0.162.205.99.host.secureserver.net:2083
DB_DATABASE_remote=name
DB_USERNAME_remote=usr
DB_PASSWORD_remote=****
在database.php文件中
'remote' => [
'driver' => 'mysql',
'url' => env('DATABASE_URL'),
'host' => $config['DB_HOST_remote'] ?? env('DB_HOST_remote', '0.162.205.99.host.secureserver.net:2083'),
'port' => $config['DB_PORT'] ?? env('DB_PORT', '3306'),
'database' => $config['DB_DATABASE_remote'] ?? env('DB_DATABASE_remote', 'forge'),
'username' => $config['DB_USERNAME_remote'] ?? env('DB_USERNAME_remote', 'forge'),
'password' => $config['DB_PASSWORD_remote'] ?? env('DB_PASSWORD_remote', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'prefix_indexes' => true,
'strict' => true,
'engine' => null,
'dump' => [
'dump_binary_path' => 'C:/xampp/mysql/bin/', // only the path, so without `mysqldump` or `pg_dump`
'use_single_transaction',
'timeout' => 60 * 5, // 5 minute timeout
],
//'dump_command_path' => 'C:/xampp/mysql/bin/',
'options' => extension_loaded('pdo_mysql') ? array_filter([
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
]) : [],
]
1条答案
按热度按时间hgtggwj01#
您必须向主机提供商发送支持票证,以便为远程连接打开SQL端口,SQL端口通常为3306