Run WordPress on SQLite.
The plugin provides a wp-content/db.php database drop-in powered by
MySQL on SQLite. WordPress and plugins continue to use the
wpdb API while the driver translates and emulates MySQL queries for SQLite.
To set up SQLite, do the following steps in your WordPress admin:
- Install and activate the plugin.
- Open Settings > SQLite integration and select Install SQLite database.
On multisite installs, use Network Admin.
Important
Enabling SQLite creates a separate SQLite database. It does not migrate data from MySQL or MariaDB. Disabling it reconnects WordPress to the original database.
See readme.txt for the plugin FAQ and changelog.
By default, the SQLite database is stored in a randomized path under
WP_CONTENT_DIR . '/database'. The full path is recorded in db-path.php
and exposed by the DB_PATH constant at runtime.
For example:
- Database path:
WP_CONTENT_DIR . '/database/.ht.020a33c5d9e5407e8e93b43e55abf62e/.ht.sqlite' - Recorded in:
WP_CONTENT_DIR . '/database/db-path.php'asreturn __DIR__ . '/...'; - Exposed by:
DB_PATH
The random path makes the database location difficult to guess when it is not otherwise protected.
To properly secure the SQLite database, define the DB_PATH constant to an
explicit path that is protected from public web access. An explicit DB_PATH
value is used as-is without randomization. Define it in wp-config.php:
// Use protected DB path that is not exposed by the web server.
define( 'DB_PATH', '/private/wordpress/database.sqlite' );Caution
An explicit DB_PATH must point to a protected location that your web server
does not expose. Store the database outside the web root and make sure it's protected.
The value of DB_PATH must be an absolute path to the SQLite database file, or :memory:
for an in-memory SQLite database. The database directory must be writable by PHP. Changing
DB_PATH selects a different database without moving an existing one.
Integrations should always read DB_PATH after WordPress loads instead of assuming
a fixed database path.
Run these commands from the repository root:
composer install
composer run check-cs
composer run wp-test-sqlite-plugin-php
composer run wp-test-sqlite-plugin-php-multisiteSee the repository README for the WordPress test environment commands.
Build an installable plugin ZIP with:
composer run build-sqlite-plugin-zipThe archive is written to build/plugin-sqlite-database-integration.zip.
- WordPress: 6.4+
- PHP: 7.2+
- PHP extensions:
pdo,pdo_sqlite - SQLite: 3.37.0+
SQLite Database Integration is licensed under the GNU General Public License v2 or later.