I am using Laravel to connect to MySQL database.
I got this exception:
PDOException
SQLSTATE[HY000] [1049] Unknown database \'forge\'
Using phpMyAdmin (or whatever you prefer), I just created a database called "forge" and re-ran the php artisan migrate
command and it all worked.
I had the same problem... If you have set your DB name and username and pass correctly in .env file and its still not working run the blow code in terminal:(this will clean the caches that left from previous apps)
php artisan cache:clear
and then run the command php artisan serve
again (if you are running it stop and run it again)
I did all of them but didn't work, I find out should stop php artisan serve(Ctrl + C) and start php artisan serve again.
Here is my response to the problem described in the question.
in cmd write:
php artisan cache:clear
then try to do this code in your terminal
php artisan serve
note: this will start again the server
Encountered this issue quite a few times, note that I'm running laravel via Vagrant. So here are the fixes that work for me:
You may try reloading your server instead of vagrant (ie MAMP)
My APP_NAME variables in .env.example
and .env
and app.php
were with space e.g. The App . Surounding that by '
and php artisan cache:clear
and setting new generated app key to APP_KEY variable through env files and relaunching the server by php artisan serve
solved this issue