Try to check out the .env file in your laravel application folder first The configuration is something like below
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
If you don't see any database configuration in the .env file, maybe you need to add connection information for your root
user in this .env file
@KhanhNguyen, Thank you.
As I stated in my original post, my database connection configuration is fine because I can run DB queries on my index page just fine, but if I try to do anything database related on my console like a
artisan migrate
or use artisan tinker
to create entries to my database, I get the error I mentioned.
For some reason, when using Vagrant-Homestead dev environment you may need to change the DB port on your environment file if you want to work with the database from a command line (artisan or tinker)
Try replacing the DB port to 33060 in the .ENV file to run php artisan and change it back to 3306 when loading you app in a web browser.
I second with Luis here, Try replacing the DB port to 33060 in the .ENV file to run php artisan and change it back to 3306 when loading you app in a web browser.
For those looking for a solution and who are in a similar position I posted my solution on StackOverflow
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community