我知道SO和Google在这个问题上备受关注,但似乎还有一个独特的问题。
错误消息:SQLSTATE [HY000] [2002]连接被拒绝
组态
'mysql' => array(
'driver' => 'mysql',
"host" => "localhost:/var/run/mysqld4.sock",
'port' => '3304',
"username" => "admin",
"password" => "admin",
"database" => "frontend_generic",
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => 'pre_',
),
我确认我的数据库正在端口3304上运行,我的前缀正确,用户,数据库和密码也正确。
对于主机,我尝试了“ localhost”,“ 127.0.0.1”,“ http://127.0.0.1 ”,甚至是服务器的实际IP地址。
仍然没有运气或变化。我尝试在本地database.php文件中使用完全相同的配置,但正如预期的那样,没有任何变化。
出于选择,我在这里错过了什么?
更新:
这是来自与此配置兼容的另一个应用程序的代码。这是Kohana,不是Laravel,但可以。
"general" => array
(
"type" => "mysql",
"connection" => array
(
"hostname" => "localhost:/var/run/mysqld4.sock",
"username" => "admin",
"password" => "admin",
"persistent" => FALSE,
"database" => "frontend_generic",
),
"table_prefix" => "pre_",
"charset" => "utf8",
"caching" => FALSE,
"profiling" => TRUE,
),
您应该将“主机”更改为实际的服务器IP地址,而不要更改其他任何内容。因此,摆脱套接字的东西。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句