PDO + SQLite = Unable to open database file

Recently I was working on a system where SQLite database was used as data storage engine. There were some problems with the development version of the application but was resolved very quickly. However I faced one problem that took over 20 minutes to get resolved.

Important notice: system was using PDO to connect with SQLite database. On one page a PDOException was thrown:

SQLSTATE[HY000]: General error: 14 unable to open database file

I double checked all .sqlite file permissions — of course everything was set up correctly. SELinux was not the problem in this case as it was completely disabled on my development box. As the all system was prepared by another programmer I was more than sure that the problem is caused by wrong permissions.


After analysing the permissions of the database file, I checked data folder permissions. While using PDO you need to remember that PDO SQLite driver must have the write permissions while performing write operations.

Small thing, only one terminal command may help you save 20 minutes while working with PDO + SQLite.

Written by

Senior Software Engineer at Home.pl

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade