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');
)