How to Fix Laravel SQLite "Database does not exist" Error
First, check whether that you made necessary environment variable changes in .env
file as described in the
How To Use SQLite Database In Laravel. If you have already tried it but not working, comment all the database related lines in the .env
file like this.
#DB_CONNECTION=mysql
#DB_HOST=127.0.0.1
#DB_PORT=3306
#DB_DATABASE=laravel
#DB_USERNAME=root
#DB_PASSWORD=
This will completely prevent loading the database configuration from the .env
file. Then open the database.php
file in the config
directory to mention the configuration directly.
But before continuing, it should not be encouraged to hard-code environment variables directly into the code. But in this scenario, the SQLite connection does not require any username or password as MySQL does.
So, change the default database connection to SQLite.
'default' => env('DB_CONNECTION', 'sqlite'),
In the connections
array, only change the database
line as following and leave other lines as they are,
'sqlite' => [
'database' => database_path('database.sqlite'),
],
After that, try to run the migration:status
command.
php artisan migrate:status