Running WordPress Without a MySQL Server: The Future of Simplicity and Portability

tl:dr: The WordPress Performance Team has released the SQLite Database Integration Plugin. However, the use of the plugin requires a working WordPress instance (with a MySQL database) to bootstrap the process. This blog post describes the process of using the SQLite plugin without requiring a MySQL server at all.

Background

WordPress has long been the go-to platform for many who are looking to build a website without the hassles of starting from scratch. One of its core features is the MySQL database, which stores all the essential data for your site. However, the landscape is evolving, and the demand for more streamlined, efficient, and less complex architectures is growing.

What if you could run WordPress without a MySQL server? It might sound like an odd idea at first, especially to WordPress professionals accustomed to traditional setups. Yet, there are significant advantages to ditching MySQL in favor of alternative storage solutions or stateless architectures. Here’s why this approach may be the standard for tomorrow.

The WordPress Performance Team has released the SQLite Database Integration Plugin. However, the use of the plugin requires a working WordPress instance (with a MySQL database) to bootstrap the process. This negates a major benefit of using SQLite, that of not needing a MySQL server. In situations like running WordPress on a Raspberry Pi, it would be best if we could boot directly into SQLite, without requiring MySQL at all.

This blog post describes the process of using the SQLite plugin without requiring a MySQL server.

No Need to Set Up a MySQL Server

The first benefit of this approach is immediately apparent: you don’t need to set up, configure, and manage a MySQL server. For those without technical expertise or those who simply want to focus more on content creation and less on database management, this is a huge plus.

Simplified Backups

Traditionally, backing up a WordPress website involves not just saving your site files but also taking a dump of your MySQL database. This could mean using extra plugins or manually exporting your database. Without a MySQL server, your backup process is simplified drastically. You only need to back up your site files, which makes the whole process quicker and easier.

Less Reliance on Plugins

The absence of a MySQL database would mean you no longer require those numerous database migration plugins that typically make moving your site from one host to another a less painful experience. Just pick up your files and go. It’s as simple as that.

Fits Well Into a CI/CD Pipeline

For developers and those familiar with DevOps concepts, a WordPress site without a MySQL server fits well into a Continuous Integration/Continuous Deployment (CI/CD) pipeline. The site’s files can be easily managed through Git, and the deployment can be automated, making your WordPress site more agile and easily adaptable to changes.

Ideal for Low-Resource Environments Like Raspberry Pi

Imagine running a full WordPress site from a Raspberry Pi. While this is possible with a traditional MySQL setup, it’s even more straightforward without it. The limited resources of a Raspberry Pi are less of a constraint when you don’t have to run a MySQL server. This enables more people to host their websites in low-cost, low-power environments.

How to Install WordPress without MySQL

This blog post shows how to install WordPress without MySQL, using the SQLite plugin released by the WordPress Performance Team.

This process assumes that you have defined a virtual directory for a website in your favorite web server, Apache, Nginx, etc. You will need phpx-pdo, phpx-pdo_sqlite, and phpx-sqlite3. It also starts with an assumption that you have downloaded the latest WordPress into the folder. Something like this:

wget https://wordpress.org/latest.tar.gz
tar -xf latest.tar.gz
sudo cp -r wordpress /var/www/sqlite-test

For the purpose of this blog post, we will assume the location to be /var/www/sqlite-test.

The first step is to download the plugin into a working directory, expand the tar.gz and copy into your web server:

wget https://github.com/WordPress/sqlite-database-integration/archive/refs/tags/v2.1.1.tar.gz
tar -xf v2.1.1.tar.gz

sudo cp -r sqlite-database-integration-2.1.1 /var/www/sqlite-test/wp-content/plugins/sqlite-database-integration

The following activities set up the plugin. The first step is to create a wp-config and add environment vars so that the plugin can be loaded:

cd /var/www/sqlite-test
sudo mv wp-config-sample.php wp-config.php

sudo sed -i '1i \
<?php \
putenv("WORDPRESS_DB_HOST=localhost"); \
putenv("WORDPRESS_DB_USER=not-used"); \
putenv("WORDPRESS_DB_PASSWORD=not-used"); \
putenv("WORDPRESS_DB_NAME=not-used"); \
?>' index.php

Then set up a db.php so that the plugin takes on the database activities.

cd wp-content

sudo cp plugins/sqlite-database-integration/db.copy db.php
sudo sed -i "s+{SQLITE_IMPLEMENTATION_FOLDER_PATH}+$(pwd)/plugins/sqlite-database-integration+g" db.php
sudo sed -i "s+{SQLITE_PLUGIN}+sqlite-database-integration/load.php+g" db.php

Create a SQLite DB:

sudo mkdir database
sudo touch database/.ht.sqlite

It’s important to set the right permissions for your web server. The following mimics the permissions for Apache used by the plugin.

sudo chown -r www-data:www-data database
sudo chmod -R 644 database
sudo chmod 766 database
sudo echo 'DENY FROM ALL' | sudo tee database/.htaccess > /dev/null

And you are good!!!

My local DNS server in my lab has a .mikey zone for local test stuff, so in my case, the following brings up the WordPress Welcome page.

http://sqlite-test.mikey

The Challenges and the Future

Of course, operating without MySQL isn’t without its set of challenges. Many existing plugins and themes are designed to work with a MySQL database. However, new tools and plugins can be developed to bridge this gap. We should also test these ideas and see how reality matches with vision, or what needs to be done to achieve the vision. I will start testing use cases such as running on a Raspberry Pi, moving sites, renaming sites, doing backups, turning on ssl, etc.

The idea of running WordPress without a MySQL database may seem like a large paradigm shift now, but as demands for efficiency, simplicity, and portability grow, we may soon find ourselves adapting to this new standard. And with the open-source community continually pushing the boundaries, it won’t be long before we see viable alternatives making this vision a reality.

Leave a Reply