【发布时间】:2017-03-08 07:17:42
【问题描述】:
我正在尝试从我的本地计算机连接Cakephp 3.x 远程数据库服务器。
但显示以下错误
错误:SQLSTATE[HY000] [2002] 没有到主机的路由
我在app.php 中的本地数据库配置如下 -
'Datasources' => [
'default' => [
'className' => 'Cake\Database\Connection',
'driver' => 'Cake\Database\Driver\Mysql',
'persistent' => false,
'host' => '192.168.1.19',
/**
* CakePHP will use the default DB port based on the driver selected
* MySQL on MAMP uses port 8889, MAMP users will want to uncomment
* the following line and set the port accordingly
*/
'port' => '3306',
'username' => 'remote_db_user',
'password' => 'my_password',
'database' => '********',
'encoding' => 'utf8',
'timezone' => 'UTC',
'flags' => [],
'cacheMetadata' => true,
'log' => false,
],
/*Other configs*/
]
关于远程服务器:
ping 192.168.1.19我的电脑上的这个 IP 没问题- 此
IP地址没有名称服务器
我该如何解决这个问题?
【问题讨论】:
-
用户名、密码和数据库呢?他们都好吗?
-
我认为在主机中你应该只提供IP,即192.168.1.19,而不是端口指定的协议(https)
-
是的!所有凭据都可以。 @ManoharKhadka
-
我也检查了没有
'https但没有发生任何事情@RohitAilani -
我修复了一些问题,并更新了问题。当前错误
Error: SQLSTATE[HY000] [2002] No route to host@ManoharKhadka
标签: mysql cakephp-3.0 mysql-error-2002