未知的mysql服务器主机,SQLSTATE [HY000] [2005]未知的MySQL服务器主机'localhost:3306'(2)...

currently i am facing above problem in laravel. basically this project is setup on mac OS x and currently i am working on it in Linux. so when i run it is on browser it give me that error. i have also changed the my database details in database file. but now this error comes. so can you please tell me how can i fix it.

Open: /var/www/laravel-projects/wit/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php

*/

public function createConnection($dsn, array $config, array $options)

{

$username = array_get($config, 'username');

$password = array_get($config, 'password');

return new PDO($dsn, $username, $password, $options);

}

Thanks

解决方案

I believe in versions of php prior to 5.5 you would use "localhost" (or the host the mysql server is running on if it's not the same host) for the 'host' parameter. If it is after version 5.5 I think you need to use "localhost:3306" (Not necessarily 3306, this is just the default mysql port, so if you changed that it will be different) . So if you are on a version of php prior to 5.5 and the code is for verion 5.5 and greater, try changing your mysql connector settings. Guessing it looks something like:

array(

'host' => "localhost:3306",

'username' => 'user',

'password' => 'pass',

'dbname' => 'database');

)

Perhaps try changing this to:

array(

'host' => "localhost",

'username' => 'user',

'password' => 'pass',

'dbname' => 'database');

)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值