Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

lukgol26's avatar

empty sqlite database after migration

  1. in .env i set DB_CONNECTION=sqlite and comment all other DB variables
  2. created database.sqlite file and sudo chmod 777 that file
  3. php artisan migrate and connect to the database through tableplus and database is empty i am using windows11, docker, wsl2, sail, ubuntu. all files in my project is 777 i have tried all solutions form internet and none of them helped. anyone knows solution?
0 likes
14 replies
Shivamyadav's avatar

try this cmd and after try to migrate it.

php artisan config:clear
Shivamyadav's avatar

@lukgol26 here you have mentioned that you have commented all the other DB variables why in .env i set DB_CONNECTION=sqlite and comment all other DB variables uncomment the all commented DB variables after that try once again

lukgol26's avatar

@Shivamyadav i have uncoment all variables in .env and php artisan config:clear and still did not working

lukgol26's avatar

@Shivamyadav i have founded the problem. when i copy db file to my windows11 pulpit i connect to the database and everything is shown but when i connect to the db whose file is in laravel project in wsl2 ubuntu it shows nothing. everything i am doing with table plus. whats the solution?

Jsanwo64's avatar

try the following

Check Database Path: Ensure that the database.sqlite file is in the correct location and that Laravel is indeed using this file for SQLite. Sometimes, the file might be created in a different directory if the path is not specified correctly.

Check Migrations: Confirm that your migrations are running correctly and actually creating the tables in the SQLite database. You can check this by looking at the migration files in the database/migrations directory and comparing them with your database schema in TablePlus.
Check Connection: Double-check your .env file to ensure that the DB_CONNECTION is set to sqlite. Also, make sure that there are no other conflicting database configurations that might be causing Laravel to use a different database driver.

File Permissions: Since you mentioned setting chmod 777 for the database.sqlite file, permissions shouldn't be an issue. However, ensure that the file is accessible and writable by the web server or the user running the Laravel commands.

Clear Cache: Sometimes, Laravel's cache can cause issues with database connections or migrations. Try running php artisan cache:clear and php artisan config:clear to clear any cached configurations.

Reset Database: If none of the above solutions work, you can try resetting the database entirely. Run php artisan migrate:fresh to drop all tables and then migrate again with php artisan migrate.

Check Docker Settings: Since you're using Docker and WSL2, ensure that your Docker setup is correctly configured to mount the Laravel project directory and that there are no issues with file paths or permissions within Docker.
lukgol26's avatar

@jsanwo64 i have founded the problem. when i copy db file to my windows11 pulpit i connect to the database and everything is shown but when i connect to the db whose file is in laravel project in wsl2 ubuntu it shows nothing. everything i am doing with table plus. whats the solution?

Jsanwo64's avatar

Ensure that the path to the SQLite database file in your Laravel project is correctly configured for the WSL2 environment. This means that the path should be something like /mnt/c/path/to/your/project/database.sqlite if your project is located in the Windows filesystem (C:\path\to\your\project).

Jsanwo64's avatar

Also, Check the permissions of the SQLite database file within the WSL2 environment. Use the ls -l command in the terminal to view the permissions. The file should be accessible and writable by the user running the Laravel commands (www-data or your WSL2 user).

lukgol26's avatar
lukgol26
OP
Best Answer
Level 3

the only solution is that you have to copy everytime your sqlite db file from ubuntu do windows11 to connect your sqlite db through tableplus. if there is better solution to do that please write it.

Please or to participate in this conversation.