We know that WordPress only supports MySQL database by default. MySQL is the most popular relational database in the world. It is natural for WordPress to use MySQL as its database. But in addition to MySQL, we can also use SQLite as WordPressdatabase systemto install and use.
How to install WordPress using SQLite database
To use SQLite as a WordPress system, we need a “Drop-in” plug-in to replace WordPress’s database processing class. This plug-in is “wp-sqlite-db”.
The installation method of wp-sqlite-db is different from that of ordinary plug-ins. We start withhttps://github.com/aaemnnosttv/wp-sqlite-dbJust download src/db.php, and then copy the db.php file to the wp-content directory, because wp-sqlite-db is a “Drop-in” type plug-in, which is used to replace WordPress’ built-in functions. As long as the file exists, the plug-in will be automatically enabled.
Then open the WordPress site installation page. We will find that there is no step to enter the MySQL database information, and we directly enter the installation interface. The next step is the same as installing WordPress using MySQL. After testing on the latest 5.2.2 version, there is no difference in use.
Benefits of installing WordPress using SQLite
Why does MySQL work so well and we need to use SQLite to install WordPress? There are several advantages:
- Low server requirements: SQLite is a file-based database that can be used as long as Nginx and PHP are on the server. Compared with the default installation method, there is one less MySQL service.
- Convenient backup: directly package the site directory to back up the entire site.
- Convenient migration: If you need to migrate the server, just package the site directory and upload it to another server. There is no need to export or import the database.
When to use SQLite
With the many benefits mentioned above, can we use SQLite to install WordPress in all cases? Of course not, there is a reason why WordPress uses MySQL as its database by default instead of SQLite.
As can be seen from the name, SQLite is a lightweight database and cannot support some complex features. Therefore, if we are developing a very simple enterprise website with only a few pages and no complex database interactions involved, there is no problem using SQLite.
Because WordPress is an open source ecosystem, there are many possibilities in terms of site architecture. Not only SQLite, WordPress can even be installed using PostgreSQL. You can search for the specific methods by yourself, so I won’t go into details here.
