在Laravel 5.2.27上拒绝用户'homestead'@'localhost'的访问(使用密码:是)

问题描述:

我一直在创建Laravel 5.2应用程序,直到今天早上,一切都运行良好.现在,当我尝试像昨天在localhost:8888/login一样登录laravel应用程序时,得到以下信息: Connector.php第55行中的 PDOException: SQLSTATE [28000] [1045]用户'homestead'@'localhost'的访问被拒绝(使用密码:是)

I have been creating a Laravel 5.2 application and everything was working perfectly until this morning. Now, when I try to login to the laravel app like I did yesterday at localhost:8888/login, I get this: PDOException in Connector.php line 55: SQLSTATE[28000] [1045] Access denied for user 'homestead'@'localhost' (using password: YES)

已安装OSX 10.10.5安全更新2016-002,需要重新启动.我认为这是在工作与不工作之间发生的唯一变化.在苹果网站上看到该更新的详细信息显然为时过早.

There was an OSX 10.10.5 security update 2016-002 that was installed and required a restart. I think this is the only thing that changed between it working and not working. It's apparently too soon to see the details of that update on the apple site.

我的.env文件如下:

My .env file looks like this:

APP_ENV=local
APP_DEBUG=true
APP_KEY=0ag8zA7SD5JRSmQTmVOpteTx82lIZF3n
APP_URL=http://localhost:8888

DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel_lic
DB_USERNAME=root
DB_PASSWORD=root

我在网上和*上搜索了答案,并尝试了以下方法:

I searched the web and * for answers and have tried the following:

  1. php artisan config:clear清除配置
  2. 在启动服务器的终端窗口中通过^ C重新启动服务器,然后使用php -S localhost:8888 -t public
  3. 重新启动它
  4. 像往常一样使用"OSX系统偏好设置"面板重新启动MySQL服务器.
  5. 使用php artisan tinker检查连接并输入DB::connection()->getDatabaseName(),结果为"laravel_lic"
  6. 在修补程序中用Config::get('database.connections.mysql.username')检查了Config数据库的用户名,结果是"root"
  7. 运行php artisan migrate:reset成功地回滚了所有迁移,然后运行php artisan migrate成功地迁移了表并使用PHPStorm中的数据库面板进行了验证,就像我自启动项目以来所做的那样.
  8. 在整个项目中进行了文本搜索,查找单词"homestead",唯一的结果在git ignore文件中.
  9. 我运行了作曲家更新,其中更新了一些Symfony内容.
  1. php artisan config:clear to clear the config
  2. Restarted the server by ^C in the terminal window where the server was started and then started it again with php -S localhost:8888 -t public
  3. Restarted the MySQL server using the OSX System Preferences panel like usual.
  4. Checked the connection using php artisan tinker and entering DB::connection()->getDatabaseName() which resulted in "laravel_lic"
  5. Checked the Config database username with Config::get('database.connections.mysql.username') in tinker which resulted in "root"
  6. ran php artisan migrate:reset which successfully rolled back all the migrations, then ran php artisan migrate which successfully migrated the tables and verified using the database panel in PHPStorm as I have been doing since I started the project.
  7. Did a text search in the entire project for the word 'homestead' and the only results were in the git ignore file.
  8. I ran composer update which updated some Symfony stuff.

我不使用宅基地.

我也没有做任何与unix_socket相关的事情.在寻找该问题的答案之前,我还没有听说过它,也没有看到任何设置,所以我怀疑那里可能有问题.

I also did NOT do anything related to the unix_socket. I hadn't heard of it until searching for answers to this question and don't see any settings for it so I doubt there could be an issue there.

过去的几个小时我一直在尝试各种事情(例如重启服务器),所以不止一次,所以我怀疑做事的顺序可能是原因.

I have been trying things for the last few hours, many more than once (such as restarting the server) so I'm doubtful the order of doing things could be a cause.

还有其他人遇到这个问题吗?还有其他什么我应该尝试使其恢复工作的方式吗?

Is anyone else having this issue? Are there any other things I should try to get it working again?

更新 2016年4月1日

UPDATE 4/1/2016

在解决了很长时间之后,仍未知道可能是什么问题,因此,我决定创建一个新的Laravel安装程序,并一点一点地重新创建该站点,并一直进行测试.好消息是,我现在启动了我的网站并开始运行,并且还在继续开发.坏消息是,我只是在复制新文件并在进行测试时进行了测试.从一个站点到另一个站点,什么都没有改变.我希望我对这个问题有一个真正的答案",但如果没有别的,我已经整理了广泛的研究和故障排除步骤,以供其他人尝试解决同一问题.

After fighting this for a long time without any progress on knowing what the problem could be, I decided to create a fresh Laravel install and recreate the site bit by bit, testing all along the way. The good news is, I now have my site up and running and have continued development. The bad news is, I was just copying over the new files and testing as I went. Nothing was changed from one site to the other. I wish I had a real "answer" for this issue but if nothing else, I've compiled the extensive research and troubleshooting steps I went through for someone else to try who comes across the same issue.

我的文件夹中仍然有问题站点,因此,如果有人确实有其他尝试要尝试的问题,或者如果我找到真正的答案,那么我将其发布.

I still have the problem site in it's folder so if anyone does have other things to try or if I find a real answer to why this was happening, I'll post it.

您将其托管在自己的专用服务器上,而不是apache服务器上.因此,在更新.env文件时需要刷新服务器. 只需停止服务器,然后使用php artisan serve重新启动即可.

You are hosting it on a its own dedicated server than an apache server. So you need to refresh your server when you update the .env file. Just stop the server and restart is again by using php artisan serve.