Connector.php第55行中的Laravel PDOException错误 [英] Laravel PDOException error in Connector.php line 55

查看:1023
本文介绍了Connector.php第55行中的Laravel PDOException错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Laravel PHP框架的初学者。这就是为什么我要从在这里(Laravel.com)。我一步步地跟着这个基本任务。但是在完成这个之后,我得到一个错误。我把错误 here。


PDOException在
中C:\xampp\htdocs\quickstart\vendor\laravel \framework\src\Illuminate\Database\Connectors\Connector.php
第55行:SQLSTATE [HY000] [1045]访问被拒绝用户
'homestead'@'localhost'(使用密码:是)

这个错误的含义是什么?

SQLSTATE [HY000] [1045]拒绝用户'homestead'@'localhost'(使用密码:YES)

这是我的 .env 文件。

  DB_HOST = localhost 
DB_DATABASE = laravel
DB_USERNAME = root
DB_PASSWORD =

我发现了类似问题在此处。但是没有适当的解决方案。



这里我从 Connector.php 添加几行(48到63) ($ dsn,array $ config,array $ options)


$ b $ $ $ $ $ $ $ b $ username = Arr :: get($ config,'username');

$ password = Arr :: get($ config,'password');

尝试{
$ pdo =新的PDO($ dsn,$ username,$ password,$ options);
} catch(Exception $ e){
$ pdo = $ this-> tryAgainIfCausedByLostConnection(
$ e,$ dsn,$ username,$ password,$ options
);
}

返回$ pdo;
}

真的,我确实得到了正确的解决方案。有谁可以给​​我正确的解决方案呢?顺便说一下,这是拉拉维尔5.2。



感谢您的高级。

解决方案


SQLSTATE [HY000] [1045]访问拒绝用户'homestead'@'localhost'(使用密码:YES)

这意味着您提供的用户名和密码不正确。如果您使用的是宅基地,则默认用户名为ir homestead ,密码为 secret 。另外,您可能需要更改数据库端口,因为默认的laravel配置将查找端口 3306 ,但宅基地端口 33060 .env 文件应该如下所示:



<$>

p $ p> DB_HOST = 127.0.0.1
DB_DATABASE = homestead
DB_USERNAME = homestead
DB_PASSWORD =秘密
DB_PORT = 33060

来源


I am beginner in Laravel PHP framework.That's why i am trying basic task from HERE (Laravel.com) .I followed this basic task step by step.But after finishing this i am getting an error .I am putting the error here.

PDOException in C:\xampp\htdocs\quickstart\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'homestead'@'localhost' (using password: YES)

What is the meaning of this error?

SQLSTATE[HY000] [1045] Access denied for user 'homestead'@'localhost' (using password: YES)

Here is my .env file.

DB_HOST=localhost
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=

I have found similar problem in here. But there is no proper solution of it.

Here i add few lines (48 to 63) from Connector.php .

public function createConnection($dsn, array $config, array $options)
{
    $username = Arr::get($config, 'username');

    $password = Arr::get($config, 'password');

    try {
        $pdo = new PDO($dsn, $username, $password, $options);
    } catch (Exception $e) {
        $pdo = $this->tryAgainIfCausedByLostConnection(
            $e, $dsn, $username, $password, $options
        );
    }

    return $pdo;
}

Really i do get right solution of it.Have anyone who can give me the right solution of it? BTW this is laravel 5.2.

Thanks in advanced.

解决方案

SQLSTATE[HY000] [1045] Access denied for user 'homestead'@'localhost' (using password: YES)

This means, that your provided username and password is incorrect. If you're using homestead, default username ir homestead and the password is secret. Also, You might need to change the database port, since the default laravel configuration will look for port 3306, but homestead runs on port 33060

So the .env file should look like this:

DB_HOST=127.0.0.1
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
DB_PORT=33060

Source

这篇关于Connector.php第55行中的Laravel PDOException错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆