When working with SQLite databases stored in WSL2 and accessing them via PhpStorm, you might encounter the following error:
Error encountered when performing Introspect schema main: [SQLITE_BUSY] The database file is locked (database is locked)
This issue arises due to SQLite’s file locking mechanisms, which are not fully compatible with WSL2’s file system when accessed through tools like PhpStorm.
Problem
When you drag and drop an SQLite file from the WSL2 folder into PhpStorm’s Database tab, PhpStorm generates a default connection URL like this:
jdbc:sqlite:\\wsl.localhost\Ubuntu\projects\database\database.sqlite
This URL does not include parameters to prevent locking issues. As a result, SQLite encounters file locks, even if no other process is actively using the database.
Solution: Modify the JDBC URL with nolock=1
To fix this issue, you need to modify the JDBC connection URL by appending the ?nolock=1
parameter. This parameter disables file locking in SQLite, making it compatible with WSL2.
Steps:
Save the configuration.
Open PhpStorm’s Database tab.
Right-click on the SQLite connection and select Properties or Edit Data Source.
Modify the JDBC URL
:plaintextCode kopierenjdbc:sqlite:file:\\wsl$\Ubuntu\projects\database\database.sqlite?nolock=1
Click Test Connection to ensure it works.
Views: 8