'How to fix Laravel 8 - "SQLSTATE[HY000] [1049] Unknown database"
I'm trying to run the following command:
php artisan migrate
When I do that, I get the following error:
Illuminate\Database\QueryException
SQLSTATE[HY000] [1049] Unknown database 'verified_db' (SQL: select * from information_schema.tables where table_schema = verified_db and table_name = migrations and table_type = 'BASE TABLE')
at C:\Users\richa\Desktop\back-office\vendor\laravel\framework\src\Illuminate\Database\Connection.php:692
688▕ // If an exception occurs when attempting to run a query, we'll format the error
689▕ // message to include the bindings with SQL, which will make this exception a
690▕ // lot more helpful to the developer instead of just the database's errors.
691▕ catch (Exception $e) {
➜ 692▕ throw new QueryException(
693▕ $query, $this->prepareBindings($bindings), $e
694▕ );
695▕ }
696▕ }
1 C:\Users\richa\Desktop\back-office\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70
PDOException::("SQLSTATE[HY000] [1049] Unknown database 'verified_db'")
2 C:\Users\richa\Desktop\back-office\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70
PDO::__construct()
I already configured the .env file with my database credentials. I hope someone can assist with this.
Solution 1:[1]
Run this command
php artisan optimize
then run
php artisan serve
i hope you will got your solution its a cache problem .
Solution 2:[2]
in MySQL Workbench *create a new schema in the connected server ~set [Schema Name] = [DB_DATABASE]='your name' run command: php artisan migrate
in phpMyAdmin *create a Database ~set [Database Name] = [DB_DATABASE]='your name' run command: php artisan migrate
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Rakesh kumar Oad |
| Solution 2 | wonderful co |
