Laravel PDOException SQLSTATE[HY000] [1049] Unknown database 'forge'

后端 未结 23 2139
醉酒成梦
醉酒成梦 2020-12-25 11:51

I am using Laravel to connect to MySQL database.

I got this exception:

PDOException
SQLSTATE[HY000] [1049] Unknown database \'forge\'
相关标签:
23条回答
  • 2020-12-25 12:35

    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.

    0 讨论(0)
  • 2020-12-25 12:35

    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)

    0 讨论(0)
  • 2020-12-25 12:36

    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.

    0 讨论(0)
  • 2020-12-25 12:36

    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

    0 讨论(0)
  • 2020-12-25 12:38

    Encountered this issue quite a few times, note that I'm running laravel via Vagrant. So here are the fixes that work for me:

    • Try again several times (refresh page)
    • Reload vagrant (vagrant reload)

    You may try reloading your server instead of vagrant (ie MAMP)

    0 讨论(0)
  • 2020-12-25 12:38

    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

    0 讨论(0)
提交回复
热议问题