Install a database

To run a Mattermost server, you need a database: either MySQL or PostgreSQL. See the database software requirements documentation for details on version support.

Tip

You can use sockets for setting up the database. See the using sockets for database documentation for details.

Install and set up a MySQL database for use by the Mattermost server.

  1. Log into the server that will host the database, and open a terminal window.

  2. Install MySQL.

  3. Run sudo mysql_secure_installation and follow the instructions.

  4. Log in to MySQL as root by running sudo mysql.

  5. Create the Mattermost user mmuser by running mysql> create user 'mmuser'@'%' identified by 'mmuser-password';.

  • Use a password that is more secure than mmuser-password.

  • The % means that mmuser can connect from any machine on the network. However, it’s more secure to use the IP address of the machine that hosts Mattermost. For example, if you install Mattermost on the machine with IP address 10.10.10.2, then use the following command: mysql> create user 'mmuser'@'10.10.10.2' identified by 'mmuser-password';

  1. Create the Mattermost database by running mysql> create database mattermost;.

  2. Grant access privileges to the user mmuser by running mysql> grant all privileges on mattermost.* to 'mmuser'@'%';.

Note

This query grants the MySQL user we just created all privileges on the database for convenience. If you need more security, use the following query to grant the user only the privileges necessary to run Mattermost: mysql> GRANT ALTER, CREATE, DELETE, DROP, INDEX, INSERT, SELECT, UPDATE, REFERENCES ON mattermost.* TO 'mmuser'@'%';

  1. Log out of MySQL by running mysql> exit. Once the database is installed and the initial setup is complete, you can install the Mattermost server.

Encountering issues with your MySQL database installation? See the MySQL installation troubleshooting documentation for details.