Appwrite supports MongoDB and MariaDB as database backends. The database is selected during installation via the setup wizard and cannot be changed after installation.
Regardless of which database you choose, the Appwrite API remains the same. Only the underlying storage engine differs.
Default database
MongoDB is the default database as of Appwrite 1.9.0.
CLI installation
If you prefer to skip the setup wizard, you can set the database directly using the --database flag:
docker run -it --rm \
--volume /var/run/docker.sock:/var/run/docker.sock \
--volume "$(pwd)"/appwrite:/usr/src/code/appwrite:rw \
--entrypoint="install" \
appwrite/appwrite:1.9.0 \
--database=mongodb
docker run -it --rm ^
--volume //var/run/docker.sock:/var/run/docker.sock ^
--volume "%cd%"/appwrite:/usr/src/code/appwrite:rw ^
--entrypoint="install" ^
appwrite/appwrite:1.9.0 ^
--database=mongodb
docker run -it --rm `
--volume /var/run/docker.sock:/var/run/docker.sock `
--volume ${pwd}/appwrite:/usr/src/code/appwrite:rw `
--entrypoint="install" `
appwrite/appwrite:1.9.0 `
--database=mongodb
Accepted values are mongodb and mariadb.
Supported databases
MongoDB
MongoDB is a document-based database and the default option for new Appwrite installations. It is configured as a replica set (rs0) automatically during installation.
- Docker image:
mongo:8.2.5 - Container name:
appwrite-mongodb - Default port:
27017
MariaDB
MariaDB is a relational SQL database. It was the default database in Appwrite versions prior to 1.9.0.
- Docker image:
mariadb:10.11 - Container name:
appwrite-mariadb - Default port:
3306
Environment variables
Both database backends use the same environment variables. The values differ depending on which database was selected during installation.
| Variable | Description | MongoDB default | MariaDB default |
_APP_DB_ADAPTER | Database adapter type | mongodb | mariadb |
_APP_DB_HOST | Database server hostname | mongodb | mariadb |
_APP_DB_PORT | Database server port | 27017 | 3306 |
_APP_DB_SCHEMA | Database name | appwrite | appwrite |
_APP_DB_USER | Database user | user | user |
_APP_DB_PASS | Database user password | password | password |
_APP_DB_ROOT_PASS | Database root password | rootsecretpassword | rootsecretpassword |
The Docker Compose profile controls which database container runs. This is set automatically by the installer:
COMPOSE_PROFILES=mongodbfor MongoDB installationsCOMPOSE_PROFILES=mariadbfor MariaDB installations
Change default passwords
Always change the default database passwords before deploying to production. Update both the environment variables and the database credentials.
Backups
For database backup procedures, see the Backups guide, which covers both MongoDB and MariaDB backup and restore commands.