Access denied for user 'homestead'@'lo

2019-07-23 04:51发布

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)

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.

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 StackOverflow for answers and have tried the following:

  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.

I'm NOT using homestead.

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?

UPDATE 4/1/2016

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.

2条回答
做自己的国王
2楼-- · 2019-07-23 05:29

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.

查看更多
劳资没心,怎么记你
3楼-- · 2019-07-23 05:38

I ran a virus scan on my Mac and lo and behold, it found some infections. After removing them, I tried the site again and it worked normally. An infection is what I assume caused the issues I had.

查看更多
登录 后发表回答