Preparing PostgreSQL for Mattermost before the application goes live
Preparing PostgreSQL for Mattermost means creating a dedicated database and login role, setting a UTF-8 collation, and granting the role ownership of the schema it needs, on PostgreSQL 15 or later. The decision you face first is where that database runs and who operates it: on servers you manage, or on a managed service such as Amazon RDS or Azure Database for PostgreSQL. Mattermost uses PostgreSQL as its only database, and the server runs as a single Linux binary, so the database choice shapes your backups, your high availability design and how you schedule upgrades. Mattermost's own documentation covers the server side, but the database settings should be decided before anyone installs the application.
Do this work before you install the Mattermost server, and certainly before you plan high availability, read replicas or a disaster recovery site. Those designs assume the database already has a known owner, a backup method and a tested restore path. The PostgreSQL schema grants also differ by major version, so confirm the exact PostgreSQL version your target Mattermost release supports in the Mattermost server releases page and in the installation guide for your platform before you pick a version. Mattermost ships monthly server releases and separate Extended Support Releases, so a database version chosen today must still be supported for the life of the server.
Ask your team a few concrete questions before you choose. Who will apply PostgreSQL minor updates and major upgrades, and how long can the chat service be unavailable during one? Does your organization already run PostgreSQL with tested point-in-time recovery, or would a managed service give you backups and failover tooling you would otherwise build yourself? If you self-manage, plan for failover tooling, since PostgreSQL does not detect a failed primary or promote a standby on its own. Ask any managed provider which PostgreSQL versions and extensions it offers, how it handles major upgrades, and whether it supports the collation and role settings Mattermost requires. Write those answers down before the installation ticket is opened.
Mattermost writes go to one primary, while reads can fan out
The diagram starts at the Mattermost application nodes in the Mattermost network. Writes travel through an optional PgBouncer pool to the PostgreSQL primary, which is the only target for writes. Read-only queries can be sent to a hot standby or to database read replicas, and the standby is also the failover target. The trust boundary sits between the application network and the database network, so confirm which hops cross it and which firewall rules allow them. Confirm with your own team how the standby is promoted, since PostgreSQL does not detect a failed primary by itself and failover tooling is the client's responsibility to select and test.
Application nodes send writes to the primary and reads to replicas, with the trust boundary between networks.
Which PostgreSQL option fits which organization
This table compares self-managed PostgreSQL, Amazon RDS for PostgreSQL and Azure Database for PostgreSQL across control, operations effort, high availability, backup and recovery, upgrades and compliance placement. Read each row as a question to answer with your platform or cloud team before you choose. The main takeaway is that managed services shift routine operations to the provider, but failover behavior, restore windows, upgrade timing and data residency still need written confirmation.
| Decision area | Self-managed PostgreSQL | Amazon RDS or Azure Database for PostgreSQL | What to confirm |
|---|---|---|---|
| Control over configuration | Full control of parameters, extensions, authentication methods and host settings | Configuration limited to exposed parameters and supported extensions | Confirm which Mattermost-required settings and extensions the service allows |
| Operations effort | Your team patches the operating system, PostgreSQL binaries and monitoring | Provider handles host patching and many maintenance tasks on a schedule you can plan around | Confirm maintenance windows and who approves them |
| High availability ownership | Your team designs replication and must add external failover tooling, since PostgreSQL does not detect primary failure on its own | Provider offers a managed standby option; confirm whether it is synchronous and how failover is triggered | Confirm failover time expectations in writing and whether Mattermost clustering needs a specific configuration |
| Backup and point-in-time recovery | Your team configures continuous archiving and tests restores | Provider provides automated backups with a retention setting you choose | Confirm retention period, restore granularity and who runs a test restore |
| Major version upgrades | Your team plans pg_upgrade, dump and restore, or logical replication, and schedules the downtime | Provider-run or customer-triggered upgrade; confirm whether it is in place and how long the service is unavailable | Confirm the supported PostgreSQL versions and the end-of-support date for your target version |
| Compliance and data location | Database sits wherever you host it, including on-premises or air-gapped networks | Database runs in the provider region you select, subject to the provider's shared responsibility terms | Confirm data residency, encryption keys, audit logging and whether your assessor accepts provider evidence |
| Best fit | Organizations with existing database operations, strict network isolation or air-gapped requirements | Organizations that want managed backups and patching and already operate within one cloud provider | Decide with your platform team which operational duties they can staff for the life of the deployment |
What changes for self-managed, RDS and Azure deployments
On infrastructure you control, your team creates the role and database, sets the collation, and operates every layer of the cluster. Nothing is provided for you, so each decision in this topic falls to your database and platform operators.
- Role and database: Create the Mattermost role and database as a superuser, set the owner to the Mattermost role, and set the encoding and collation to UTF-8 at creation time, since changing them later is not practical.
- Schema grants: On PostgreSQL 15 and later, grant the Mattermost role ownership of the
publicschema or explicit CREATE rights on it, because PUBLIC no longer holds that privilege by default. - Authentication: Set SCRAM password encryption and limit
pg_hba.confentries to the Mattermost hosts and TLS connections. The PostgreSQL authentication methods page lists the alternatives you can select. - Replication and failover: Your team chooses synchronous or asynchronous standbys and selects any external failover tool, because PostgreSQL does not detect a failed primary or promote a standby on its own.
- Backups and upgrades: Your team owns WAL archiving, point-in-time recovery tests and major upgrades. Minor releases replace executables and need a restart, while major upgrades use dump and restore, pg_upgrade or logical replication.
Check the server version against the support dates, and confirm pg_hba.conf, the archive command and the standby settings on the server itself.
Amazon RDS for PostgreSQL manages the instance, host patching and the mechanics of backups and standbys, but the Mattermost role, grants and connection settings remain your work. Your team runs the SQL from a host that can reach the instance endpoint, and it confirms which provider options apply to your engine version.
- Role and database: The master user you set at instance creation creates the Mattermost role and database. RDS does not create them, so the SQL runs from a bastion or application subnet that can reach the endpoint.
- Encoding and collation: Confirm the database uses UTF-8 and the collation you planned by querying the database catalog before loading data, because the collation is fixed when the database is created.
- Schema grants: Run the PostgreSQL 15 grant as the master user or the schema owner so the Mattermost role can create tables in
public. - Authentication: Require TLS through the parameter group and confirm in the console which password or IAM-based methods your engine version supports.
- Failover, backups and upgrades: Multi-AZ, automated backups and major version upgrades are provider settings you configure and test. Your team still owns restore drills and the Mattermost-side plan for reconnecting after a failover.
Verify the parameter group, the backup retention window, the Multi-AZ setting and the engine version support date in the RDS console.
Azure Database for PostgreSQL runs the server, its patching and its built-in backup features, while your team still creates the Mattermost role, sets grants and decides how clients authenticate. Confirm in the Azure portal which deployment option and networking model your subscription offers, because those choices change how the server is reached.
- Role and database: Connect as the administrator account created with the server, then create the Mattermost role and database. Azure does not create them, so confirm the role can log in from the Mattermost network path.
- Encoding and collation: Confirm the database was created with UTF-8 and the expected collation with a catalog query, since the collation cannot be changed on an existing database.
- Schema grants: Under PostgreSQL 15 and later, grant the Mattermost role ownership of
publicor explicit create rights, using the administrator account. - Authentication: Enforce encrypted connections and confirm which methods, such as password or Microsoft Entra ID authentication, the server supports. Document which one Mattermost uses.
- Failover, backups and upgrades: High availability, geo-redundant backup and point-in-time restore are provider features to configure and test. Your team owns restore verification and the process for major version upgrades.
Verify the server version, network access rules, backup retention and high availability settings in the Azure portal before you finalize the Mattermost connection string.
Choosing PostgreSQL 15 or later and the UTF-8 collation
Set the PostgreSQL major version and the database collation before the first Mattermost start, because both are expensive to change once the database holds data. Mattermost runs on PostgreSQL, and this topic starts from PostgreSQL 15 or later. Version 15 is the oldest version you should install for a new deployment, but it is not the best long-term choice. Per the PostgreSQL versioning policy, supported major versions are 18 (final release November 14, 2030), 17 (to November 8, 2029), 16 (to November 9, 2028), 15 (to November 11, 2027) and 14 (to November 12, 2026). Choose the newest version your Mattermost release supports, then check its end-of-support date against your planned service life. A version that ends support during the first year of operation forces an upgrade project almost immediately.
The versioning policy gives each major version five years of support from its initial release, and it ships a new major version about once a year. Minor releases, by contrast, arrive at least every three months, never change the internal storage format, and are applied by replacing executables and restarting. Major upgrades are a different operation that needs pg_dumpall and restore, pg_upgrade, or logical replication, as the upgrading a PostgreSQL cluster guide describes. Plan your patch cadence around minor releases, and schedule major upgrades separately. Ask your Mattermost support contact which PostgreSQL versions your target server release certifies, since the database version you pick must be on that list.
The encoding and collation are the other decision you cannot easily reverse. Create the Mattermost database with UTF-8 encoding so that message text, usernames and file names in any language store correctly, and confirm the collation string against Mattermost's current database setup guidance before running CREATE DATABASE. Changing collation later generally means a dump, a recreated database and a re-import, and indexes built on text columns must be rebuilt. Record the chosen version, encoding and collation in your build runbook so that a restore or a replacement database matches the original. If your platform team uses a managed PostgreSQL service, confirm with the provider which versions and collations it offers before you commit to a design.
How to create the Mattermost database and user on PostgreSQL
This sequence gives Mattermost a dedicated PostgreSQL database and login role with UTF-8 encoding, scoped privileges, restricted network access and a verified connection before the application is installed. Each step ends with a check you can record as evidence.
Confirm the PostgreSQL version and server settings
The database administrator connects to the server with psql and runs SELECT version(); to confirm the server is PostgreSQL 15 or later and a version that is still in support. Check the server encoding with SHOW server_encoding; and note the host, port and listen_addresses setting, since these control which hosts can reach the database. Supported major versions and end-of-life dates are listed in the PostgreSQL versioning policy, so confirm the release against that page before going further. Done means you have a written record of the version, encoding and listening address.
Create a dedicated login role with a stored secret
The database administrator creates a login role for Mattermost only, for example with CREATE ROLE mattermost LOGIN PASSWORD set from a generated value, and sets password_encryption to scram-sha-256 so the stored hash uses SCRAM. The password is generated outside the database, stored in your secrets manager and never written into shell history or a shared file. Do not grant the role superuser, createdb or createrole rights. Done means the role exists, SELECT rolsuper, rolcreatedb FROM pg_roles WHERE rolname = 'mattermost'; returns false for both, and the password hash begins with the SCRAM prefix in pg_authid.
Create the database with UTF-8 encoding and collation
The administrator creates the database owned by the Mattermost role, using UTF-8 encoding and the collation that the Mattermost installation documentation specifies for your release. Confirm the required collation against that documentation before running CREATE DATABASE, because the encoding and collation cannot be changed later without recreating the database. Template databases must match the encoding, so use template0 if your template1 differs. Done means a catalog query on pg_database shows the expected encoding, datcollate and datctype values for the mattermost database.
Grant the role the rights it needs on the database
Make the Mattermost role the owner of its database, or grant it CONNECT, CREATE and TEMPORARY rights on the database if ownership does not suit your controls. Ownership is the simpler option for a dedicated database because the role can manage its own objects during upgrades. Revoke the default CONNECT right from PUBLIC on the new database so that other roles cannot open it. Done means SELECT datname, pg_get_userbyid(datdba) FROM pg_database; shows the Mattermost role as owner and a privilege check for an unrelated test role returns no CONNECT access.
Set schema rights for PostgreSQL 15 and later
From PostgreSQL 15, the public schema no longer grants CREATE to all users by default, so the Mattermost role needs explicit rights to create tables. Connect to the mattermost database and either make the role the owner of the public schema with ALTER SCHEMA public OWNER TO mattermost, or grant USAGE and CREATE on a dedicated schema and set that schema as the role's search path. Choose one approach and record it, since upgrades and later tooling depend on which schema holds the objects. Done means has_schema_privilege('mattermost', 'public', 'CREATE') returns true and the same check against any other role returns false.
Restrict access in pg_hba.conf to Mattermost hosts
Edit pg_hba.conf so that the only host-based entries for the mattermost database allow the IP addresses or subnets of the Mattermost application servers, with the scram-sha-256 authentication method. Remove or avoid any trust or password entries that match all hosts, and place the Mattermost rules above any broad rules. Reload the configuration with SELECT pg_reload_conf(); and confirm listen_addresses includes only the interfaces that need to receive connections. Done means SELECT * FROM pg_hba_file_rules; lists the Mattermost entry, and a connection attempt from an unlisted host is rejected.
Verify isolation from other databases
Connect as the Mattermost role to a database that it does not own, such as postgres or a test database, and confirm the connection is refused or that the role cannot read tables there. Also confirm the role cannot create other roles or databases by checking pg_roles as in the earlier step. This check shows that the role's rights stop at the Mattermost database. Done means each attempted connection to another database fails with a permission error, and the results are written into the change record.
Test the connection from a Mattermost host
From the host that will run Mattermost, install the PostgreSQL client tools and run psql with the host, port, database and mattermost role, supplying the password from the secrets manager. Run SHOW server_encoding; and SELECT current_user; to confirm the session is the expected role and the database uses the right encoding. Repeat the test from each application server that will connect, including any standby or proxy path you plan to use. Done means each host connects with SCRAM authentication and returns the expected user and encoding, and the test is recorded before the Mattermost application is installed.
Security controls for the Mattermost database
The database holds every message, file reference and account record Mattermost stores, so its access controls matter as much as the application's. The controls below work together: how the application authenticates, where it can connect from, how traffic is protected in transit, and who can change the data.
SCRAM password authentication
Use SCRAM-SHA-256 for the Mattermost role's password rather than MD5. PostgreSQL 18 deprecated MD5 password authentication in favor of SCRAM, so a new deployment should not start on MD5 and any existing role should be re-keyed. Confirm the password_encryption setting on your server and the authentication method in pg_hba.conf before go-live.
Host-based access rules
Limit which addresses may reach the database port through pg_hba.conf so that only the Mattermost application servers, and any approved replica or admin hosts, are listed. Every other source should fall through to a reject rule. Check the rules after each change to the Mattermost node pool, because a new node that is not listed will fail to connect in a way that looks like a network fault.
TLS for client connections
Enable TLS on the server and require it for the Mattermost connection so that credentials and message data are not sent in clear text across the network. Decide whether the server certificate will be checked against a private CA, and confirm that the Mattermost database connection settings verify the certificate chain. If the database sits in a managed service, confirm that the service enforces TLS for every client.
Separate application and admin roles
Create one role that owns the Mattermost schema or has only the grants it needs, and keep superuser and schema-change roles separate from it. The application role should not be able to create roles or drop databases. Document who holds each role, since upgrades and migrations usually need a privileged account for a short period and that account should be revoked afterward.
Database credential storage
Keep the Mattermost database password out of files that are readable by other users or committed to source control. Store it in a secrets manager or a restricted-permission file and reference it from configuration, and rotate it on a schedule your team can run. Confirm how your Mattermost install reads its connection string, since a password placed in config.json is visible to anyone who can read that file.
Connection and audit logging
Turn on PostgreSQL logging for connection attempts, disconnections and failed authentications so that unusual access can be investigated. Decide where the logs go, how long they are kept, and who can read them, because they can contain usernames and client addresses. Confirm with your compliance team which log retention and review controls your framework requires, and whether an external authentication source such as LDAP, GSSAPI or certificate authentication is needed to meet your identity design.
Backups, point-in-time recovery and failover planning
The Mattermost database holds the messages, channels, users and most configuration for your workspace, so backup and recovery design belongs in the database plan before go-live, not after the first incident. Decide early how far back you need to recover, how much data loss is acceptable and who performs a restore. PostgreSQL documents continuous archiving (base backups plus archived write-ahead log files) as the basis for point-in-time recovery, which lets you restore the cluster to a chosen moment rather than only to the last nightly dump. Set archive_mode and archive_command (or an archiving tool you select) on the Mattermost database server, store the archive off the primary host, and confirm the retention period with your compliance team, since it must match any message retention policy you configure in Mattermost. A backup that has never been restored is not yet a recovery plan, so schedule a restore into a separate host and run Mattermost against it.
Hot standby servers give you a second copy of the database that answers read-only queries. PostgreSQL supports synchronous replication, where a commit waits until a standby confirms it, and asynchronous replication, where the primary does not wait. Synchronous replication protects against losing committed messages during a failover but adds latency to every write, while asynchronous replication is faster but can lose the most recent transactions. Make this choice with the business owner of the chat data, and document the expected data loss in your recovery objectives. Note that PostgreSQL does not itself detect a failed primary and promote a standby, so automatic failover needs external tooling that your team must select, configure and test. Until that tooling is proven in a rehearsal, failover is a manual, documented procedure.
Mattermost high availability, which uses redundant application servers, redundant database servers and redundant load balancers, is available only on the Enterprise and Enterprise Advanced plans, according to Mattermost. Database read replicas and search replicas are also tied to the plan and to how your database is designed, so confirm both the plan entitlement and the supported replica topology with Mattermost before you commit to an architecture. Ask Mattermost which replica and failover configurations it supports, how it expects connections to route between primary and standbys, and what recovery steps it documents. Record those answers in your database design so that the backup, replication and failover choices match what the application supports.
Limits to confirm before you commit to a database design
Several limits on a Mattermost database design depend on versions, plans and the managed service you pick, so they should be confirmed before any build starts. The cards below cover the checks that most often change the design. Each one is worth settling in writing with your vendor or your own environment.
Mattermost version and PostgreSQL support
Confirm which Mattermost server version you will run and which PostgreSQL major versions that release supports before you pick one. Mattermost publishes monthly releases and Extended Support Releases with separate end-of-support dates, so the server version sets the window in which your database choice must stay supported. Check the compatibility statement for your exact release and record it in the design document.
- Oldest PostgreSQL in our plan
- 15
Managed service collation, extensions and privileges
If you choose a managed service, confirm that it lets you create a database with the UTF-8 collation you need and that the account you receive can own the schema and make the grants Mattermost requires. Ask whether any extensions the server relies on are offered and whether the provider restricts superuser-level actions. A service that hides these controls can force a rebuild later, so ask the provider to show them in a test instance.
PgBouncer compatibility and pool settings
If you plan to place PgBouncer between Mattermost and PostgreSQL, confirm how your Mattermost release interacts with the pool mode you choose, and test transaction and session behavior under load. Pooling settings also determine how many server connections the database accepts, so record the pool size, the maximum client connections and the database connection limit together. Check these values against the PgBouncer documentation for your version.
PgBouncer projectReplica and high availability features by plan
Mattermost documents database read replicas and high availability clustering, but these features depend on your license tier. Confirm with Mattermost sales which plan includes the replica, search and clustering features you need, and whether your managed database service supports the replication topology that design assumes. A design that relies on a feature outside your plan will need rework at contract time.
Mattermost pricingPostgreSQL end-of-support date for your major version
Confirm the end-of-support date for the PostgreSQL major version you select and compare it with your planned Mattermost upgrade schedule. A database that leaves support before your next server upgrade forces a second migration within the life of the system. Ask whether your provider's own support window for that major version is shorter than the community window, and plan the major upgrade path before go-live.
Versioning policyData residency and air-gapped constraints
Confirm where the managed service stores backups, replicas and snapshots, and whether those locations meet your data residency rules. If your environment is air-gapped or has restricted egress, confirm that the managed service can run without external control-plane calls and that you can restore it from a copy you hold. A managed service that cannot operate under these constraints rules out that option before any other comparison.
Questions buyers ask before preparing PostgreSQL for Mattermost
What does preparing PostgreSQL for Mattermost cost, and what drives the price?
The cost comes from the people doing the work and from the infrastructure underneath it. You pay for database administration time to create the Mattermost database, the user, the UTF-8 collation and the schema ownership grants, then for the servers or managed service that host it. Recurring costs include the cloud or data center capacity, backup storage, and monitoring. If you want high availability, add the cost of standby servers, failover tooling and the testing that proves failover works. DeployOpen does not publish prices. Ask any provider for a written scope that lists each of these items separately, with one-time setup and recurring operations shown on different lines so you can compare options fairly.
How long does the PostgreSQL setup take for a Mattermost deployment?
Duration depends on how many environments you need, whether the database is new or migrated, and how much high availability and recovery testing is in scope. A single development database with a standard user and collation is usually the shortest path. Production work takes longer because it includes access approvals, change windows, a test restore and sign-off. Migrating an existing database adds export, import and validation time. Ask for a timeline in the written scope with named milestones, and confirm which dependencies (network access, cloud accounts, approvals) sit with your team.
Can our own team prepare PostgreSQL for Mattermost without outside help?
Yes, if your team has working experience with PostgreSQL administration. The core tasks are creating the role and database, setting the collation, granting schema ownership correctly for PostgreSQL 15 and later, configuring client authentication, and confirming that the Mattermost server connects. The harder skills are backup and point-in-time recovery, replication, and failover design, since PostgreSQL does not detect a failed primary or promote a standby by itself. Assess whether someone on your team has run these in production before, and whether they can own the work after go-live.
Does Amazon RDS or Azure Database for PostgreSQL remove the database work?
A managed service removes some tasks, such as operating system patching, provisioning replicas and some backup mechanics. It does not remove the decisions that matter to Mattermost. You still create the Mattermost database and user, choose the collation, set the schema ownership grants, control network access, define retention and recovery targets, and decide how upgrades to a supported major version happen. Review the provider's documentation for each of these settings, and confirm the exact features and versions available in your region and account before you commit to a design.
What do we need to provide for a PostgreSQL setup engagement?
Expect to provide access to the target environment, such as cloud accounts, database servers or a managed service console, plus a network path from the Mattermost application servers. You will also need named approvers, change windows for production work, and a place to run a test restore so recovery is proven rather than assumed. Sign-off should cover the database configuration, the backup and restore results, and the list of open risks. Confirm in the written scope who provides each item and by what date, because delays in access often drive the schedule more than the technical work.
How do we confirm that our chosen PostgreSQL major version is supported?
Check the PostgreSQL versioning policy, which lists each major version with its end-of-support date. Versions 14 through 18 were supported at the time of the supplied research, with 14 ending in November 2026 and 15 ending in November 2027, so a version you choose today may need an upgrade within the life of the deployment. Confirm the current list before you install, and confirm that your Mattermost release supports the PostgreSQL version you plan to use. Plan the upgrade path up front, since logical replication and pg_upgrade are the documented options for major upgrades.
How DeployOpen scopes and delivers the PostgreSQL work for Mattermost
DeployOpen approaches the PostgreSQL work for Mattermost as a written, fixed-scope engagement inside infrastructure you control. We agree the database version, collation, ownership model and hosting choice before any build starts, then hand over a database your team can operate.
How we scope
- Confirm the Mattermost release line and the PostgreSQL major version it requires before any build starts.
- Record whether PostgreSQL runs self-managed on your servers or on Amazon RDS or Azure Database for PostgreSQL.
- Agree in writing the database, role, collation and schema ownership model, plus who owns backups and upgrades.
How we build
- Create the Mattermost database and login role with UTF-8 collation and the schema ownership grants for PostgreSQL 15 or later.
- Configure client authentication and network access so only the Mattermost application servers can reach the database.
- Test connectivity, restore from a backup and confirm the Mattermost application starts cleanly against the new database.
How we hand over
- Deliver a written record of database names, roles, extensions, authentication settings and network rules.
- Document the backup, restore and point-in-time recovery procedure and the steps your team runs to verify them.
- Walk your database, platform and security staff through the upgrade path for the PostgreSQL major version you chose.
How we support
- Ongoing support, PostgreSQL minor updates and planned major upgrades can be covered by a retainer.
- Retainers can include routine checks of backups, connection capacity and the PostgreSQL support calendar.
- Ask for a quote that separates the one-time build from any recurring support, testing or upgrade work.

