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

后端 未结 23 2137
醉酒成梦
醉酒成梦 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:41

    clear your Cache php artisan cache:clear and then restart your server php artisan serve 127.0.0.1:8000

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

    Note: Once it happened that I accidentally had a space before my database name such as mydatabase instead of mydatabase, phpmyadmin won't show the space, but if you run it from the command line interface of mysql, such as mysql -u the_user -p then show databases, you'll be able to see the space.

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

    sometimes its because DB_CONNECTION=mysql and you want to use SQLite database. A solution to that is to make DB_CONNECTION=sqlite. hope it helps

    DB_CONNECTION=mysql
    DB_HOST=127.0.0.1
    DB_PORT=3306
    DB_DATABASE=C:\xampp\htdocs\jbtibl\database\database.sqlite
    DB_USERNAME=root
    DB_PASSWORD=
    
    0 讨论(0)
  • 2020-12-25 12:47

    first clear your cache using this command

    php artisan cache:clear
    

    Then restart the server using this command

    php artisan serve
    
    0 讨论(0)
  • 2020-12-25 12:48
    1. Stop the server then run php artisan cache:clear.
    2. Start the server and should work now
    0 讨论(0)
提交回复
热议问题