I am using Laravel to connect to MySQL database.
I got this exception:
PDOException
SQLSTATE[HY000] [1049] Unknown database \'forge\'
clear your Cache php artisan cache:clear and then restart your server php artisan serve 127.0.0.1:8000
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.
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=
first clear your cache using this command
php artisan cache:clear
Then restart the server using this command
php artisan serve
php artisan cache:clear.