SQLite database path in .env My project unable to connect to SQLite database under Sail. Does DB_DATABASE value is incorrect?
.env
DB_CONNECTION=sqlite
# DB_HOST=localhost
# DB_PORT=3306
DB_DATABASE=database\database.sqlite
# DB_USERNAME=sail
# DB_PASSWORD=password
I tried to use:
DB_DATABASE="database\database.sqlite"
But it failed! I think this related to absolute/relative path issue. Does it?
$ docker exec -it 1b84e0207e1d ls database
database.sqlite factories migrations seeders
Dont set it in your env file. Just give it the filename if needed at resolved it in database.php
'database' => database_path(env('DB_DATABASE', 'database.sqlite')),
But in your case, you can just remove it from .env and it should work
@Sinnbeck I modified it a little bit:
'database' => env('DB_DATABASE/..', database_path('database.sqlite')),
That is the default SQLite database path; it shouldn't need the environment variable at all. In any case, make sure the directory separator is correct; for Linux it is /
database/database.sqlite
@tykus nop, doesn't work.
Any way, thank you. @sinnbeck suggestion fixed the issue.
@mbnoimi it doesn't work to comment out the line in .env - and use the default?
@tykus This worked for me
DB_CONNECTION=sqlite
# DB_HOST=localhost
# DB_PORT=3306
# DB_DATABASE=database.sqlite
# DB_USERNAME=sail
# DB_PASSWORD=password
@mbnoimi right... like I said:
That is the default SQLite database path; it shouldn't need the environment variable at all.
@mbnoimi And I said :)
But in your case, you can just remove it from .env and it should work
Please sign in or create an account to participate in this conversation.