Database (database/database.sqlite) does not exist. Database works from artisan tinker

99封情书 提交于 2019-12-05 01:07:36

You need to use full path, something like:

DB_DATABASE=/home/laravel-project/database/database.sqlite

If you remove DB_DATABASE=... from your .env file and use the path in the config/database.php:

'database' => env('DB_DATABASE', database_path('database.sqlite')),...

(if your database.sqlite file is in database/ folder), it will work, too.

I ran the following commands:

php artisan config:cache

php artisan config:clear

php artisan serve - restarted the server

Sarwar Sikder

In config/database.php file:

'sqlite' => [
              'driver' => 'sqlite',
              'database' => dirname(__DIR__).'/database/database.sqlite',
            ],

Then run following command:

php artisan config:cache
php artisan config:clear

I think, that the problem here was because of Homestead. Absolute path to the database.sqlite file on local machine is not the same as the virtual machine one has.

In my case a had to set:

DB_DATABASE=/home/vagrant/code/database/database.sqlite

Or, you can just comment out this line and you are ready to go.

#DB_DATABASE=

For those who still face this issue: https://laracasts.com/discuss/channels/general-discussion/database-databasedatabasesqlite-does-not-exist-error-on-running?page=1

Since sqlite only require DB_CONNECTION=sqlite in .env file so you just remove the other:

DB_HOST
DB_PORT
DB_DATABASE
DB_USERNAME
DB_PASSWORD

then save and run migration again. This was how I solved the problem. Cheers!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!