Multi-database service support
Besides LeanCloud, Waline also supports a variety of databases, including MySQL, PostgreSQL, SQLite and MongoDB.
You only need to configure environment variables, and Waline will automatically switch to the corresponding data storage service based on the environment variables you configure.
https://mongodb.com official provides 512M MongoDB database support for free. The following are the environment variables that need to be configured to use MongoDB database.
|127.0.0.1||MongoDB server address, support array format|
|27017||MongoDB server port, support array format|
|✅||MongoDB database name|
|✅||MongoDB server username|
|✅||MongoDB server password|
|MongoDB replica set|
|MongoDB auth source|
|use SSL connection|
Here is an example configuration for mongodb.com. Please note that you need set as JSON style for
MONGO_PORT when you has mulitple hosts.
MONGO_HOST=["cluster0-shard-00-00.p4edw.mongodb.net","cluster0-shard-00-01.p4edw.mongodb.net","cluster0-shard-00-02.p4edw.mongodb.net"] MONGO_PORT=[27017,27017,27017,27017] MONGO_DB=waline MONGO_USER=admin MONGO_PASSWORD=xxxx MONGO_REPLICASET=atlas-12cebf-shard-0 MONGO_AUTHSOURCE=admin MONGO_OPT_SSL=true
Using MySQL to store data is also a good choise. Besides our own MySQL service, we can also use https://freedb.tech, which provides 100M of database support for free, or PlanetScale which provides 10GB.
If you want to use MySQL as storage, you need to import waline.sql first to create table and table structure, then set these environment variables in project.
|127.0.0.1||MySQL server address|
|3306||MySQL server port|
|✅||MySQL database name|
|✅||MySQL server username|
|✅||MySQL server password|
|MySQL table prefix|
|MySQL table charset|
|set to |
Download waline.sqlite to your server if you want to use SQLite. Then set these environment variables in project.
|✅||SQLite storage file path, not include file name|
|waline||SQLite storage file name, change it if your filenamed is not waline|
|SQLite table prefix|
|✅||Random String for login token generator|
|127.0.0.1||PostgreSQL server address|
|3211||PostgreSQL server port|
|✅||PostgreSQL database name|
|✅||PostgreSQL server username|
|✅||PostgreSQL server password|
|PostgreSQL table prefix|
|set to |
Waline supports storing comment data in a CSV file on GitHub. To use GitHub as data storage, you need to apply for Personal access tokens. You can click Generate new token to apply it at https://github.com/settings/tokens. Check the repo option in permission to obtain read and write permissions for repositories.
|GITHUB_TOKEN||✅||Personal access tokens|
|GITHUB_REPO||✅||repository name, such as |
|GITHUB_PATH||The data storage directory, such as |
Due to preformance, using GitHub is not recommanded.
Deta provides Deta Base free database support, which can be used even if it is not deployed on Deta. If deployed on Deta, there is no need to configure any environment variables. By default, Waline will use Deta Base as the database to store data. If it is deployed elsewhere, the following environment variables need to be configured.
|✅||Deta project secret key|
Besides above database storage, support for other storage services can also be added.
If you want to help Waline supporting more storage services, you can fork the project and inherit the base class and then implement the
delete() methods of the corresponding storage service and submit the PR.