I have started my first website (in development) with a simple authentication structure. When I run my website with Homestead, the authentication doesn't work. But when I serve the website using localhost:8000 (i.e. - php artisan serve) the authentication works fine. (In both instances, the home page works, the login screen comes up...its just that with the latter approach I gain access while with the former I get an the detailed 'development' error explanation.)
The error message is the one I get above: "SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES)" (and yes, I know to not use root once I go live)
Don't they both look to the env file for access (i.e. - database name, user, password)? If so, wouldn't that suggest I don't really have a authentication issue, but that its just denying access on some other grounds and throwing the error above?
I am a finance guy trying to learn to code as a hobby...I apologize if this is a 'softball' question...
You need first to install my sql at you operating system and its very simple you can install MAMP if you use mac and Xampp if you use linux or windows and after finish installation go to PHPMYADMIN and create new database and update
DATABASE_NAME with the one you created, by default in Xampp there are (root) user you can set your DATABASE_USERNAME to root and if you use xampp DB_PASSWORD= (empty not type any thing here) or if you use mama type (root)
Please remember after any update in your .env file you should run:
php artisan cache:clear
Hope this help
You could try doing Vagrant SSH, then CDing into your project directory. Then do mysql -u root -p and enter your password. Report back with what happens.
When running Vagrant, the database resides in the vagrant machine, rather than on your local machine, which is what happens when you run php artisan serve. If after creating your vagrant box, you haven't done vagrant ssh, cd'd into your project directory, and done a php artisan migrate, then you'll need to.
@ mahmoud_eid - Thanks for the advice, but I think what you are describing avoids the use of Homestead (?), which is what I am trying to use. I was able to get it running on my machine using typical install / packages...
@ZetecVan - Thanks for you help, I think you may have found the answer. When I ssh'd into the virtual machine and tried to access MySql, it wouldn't let me do so using the new password I set up in my .env file. When I tried using the 'default' password per the laraval documentation of 'secret', however, it gave me access.
Its almost like I need to re-run something to get it to see my new password? For the time being, I just went back to 'secret' though I will obviously change if I ever go to production.