How to Install Mattermost Server on Ubuntu Linux

text editor
text editor

We previously showed you how to install the Mattermost desktop app on Ubuntu. This post shows you how to install the Mattermost server. Then, you’ll learn how to install MariaDB and download and configure the Mattermost server.

Mattermost is an open-source alternative to the Slack messaging platform. It allows teams to communicate and collaborate securely from behind the company’s firewall.

Mattermost brings teams together to collaborate on projects so work can get done as quickly and efficiently as possible. Whether you’re a small or large enterprise, Mattermost can help your team communicate and collaborate. These conversations will be available on the desktop, mobile devices, and everywhere you have Mattermost installed.

Mattermost helps you:

  • Discuss topics in private groups, one-to-one or team-wide
  • Easily share and view image files
  • Connect in-house systems with webhooks and Slack-compatible integrations

For more about Mattermost, visit its homepage.

Caution: Mattermost for Linux is in beta. New features are still being added, and potential issues are being ironed out. When you’re ready to install Mattermost for Linux, follow the steps below:

Install MariaDB Database Server

MariaDB database server is a great place to start when looking at open-source database servers with Mattermost. To install MariaDB run the commands below.

sudo apt update
sudo apt-get install mariadb-server mariadb-client

After installing MariaDB, the commands below can stop, start and enable the MariaDB service to start up when the server boots.

Run these on Ubuntu 16.04 LTS

sudo systemctl stop mysql.service
sudo systemctl start mysql.service
sudo systemctl enable mysql.service

Run these on Ubuntu 17.10 and 18.04 LTS

sudo systemctl stop mariadb.service
sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service

After that, run the commands below to secure the MariaDB server by creating a root password and disallowing remote root access.

sudo mysql_secure_installation

When prompted, answer the questions below by following the guide.

  • Enter current password for root (enter for none): Just press the Enter
  • Set root password? [Y/n]: Y
  • New password: Enter password
  • Re-enter new password: Repeat password
  • Remove anonymous users? [Y/n]: Y
  • Disallow root login remotely? [Y/n]: Y
  • Remove test database and access to it? [Y/n]:  Y
  • Reload privilege tables now? [Y/n]:  Y

Restart MariaDB server

sudo systemctl restart mariadb.service

After installing the MariaDB server, continue below to create the Mattermost database and database user account.

Now that you’ve installed all the required packages, continue below to start configuring the servers. First, run the commands below to create a blank Mattermost database.

Run the commands below to log on to the database server. When prompted for a password, type the root password you created above.

sudo mysql -u root -p

Then create a database called mattermost


Create a database user called mattermostuser with a new password

CREATE USER 'mattermostuser'@'localhost' IDENTIFIED BY 'new_password_here';

Then grant the user full access to the database.

GRANT ALL ON mattermost.* TO 'mattermostuser'@'localhost' IDENTIFIED BY 'user_password_here' WITH GRANT OPTION;

Finally, save your changes and exit.


Download and Configure Mattermost Server

After setting up Mattermost, run the commands below to download the Mattermost server archive.

cd /tmp && wget

After downloading the archive, run the commands below to extract it. And move it to the /opt directory.

tar -xvzf mattermost*.gz
sudo mv mattermost /opt

Next, create a storage directory for files.

sudo mkdir /opt/mattermost/data

The storage directory will contain all the files and images your users post to Mattermost. You must ensure the drive is large enough to hold the anticipated number of uploaded files and images.

Next, set up a system user and group called matter most to run this service and set the ownership and permissions. Finally, create the Mattermost user and group by running the commands below:

sudo useradd --system --user-group mattermost

Set the user and group matter most as the owner of the Mattermost files:

sudo chown -R mattermost:mattermost /opt/mattermost

Give write permissions to the matter most group:

sudo chmod -R g+w /opt/mattermost

After that, run the commands below to edit Mattermost database connection info.

sudo nano /opt/mattermost/config/config.json

Then make the highlighted changes below and save the file.

"SqlSettings": {
        "DriverName": "mysql",
        "DataSource": "mattermostuser:new_password_here@tcp(localhost:3306)/mattermost?charset=utf8mb4,utf8&readTimeout=30s&writeTimeout=$
        "DataSourceReplicas": [],
        "DataSourceSearchReplicas": [],
        "MaxIdleConns": 20,
        "MaxOpenConns": 300,
        "Trace": false,
        "AtRestEncryptKey": "",
        "QueryTimeout": 30

Save the file.

After that, run the commands below to create a systemd service unit file.

sudo nano /etc/systemd/system/mattermost.service

Then copy and paste the content below into the file and save it.




For Ubuntu 16.04, release MariaDB.service with MySQL. service.

Next, run the commands below to start the Mattermost service.

sudo systemctl daemon-reload
sudo systemctl start mattermost.service
sudo systemctl enable mattermost.service

Now open your browser and browse to the server hostname or IP address followed by port # 8065


You should see the Mattermost signup page.

Mattermost server install ubuntu

Create an admin account and sign on.

Matter most server

You may also like the post below:

Posted by

I love computers; maybe way too much. What I learned I try to share at


  1. In the official document,
    If you are using MySQL:

    Set “DriverName” to “mysql”
    Set “DataSource” to the following value, replacing and with the appropriate values. Also make sure that the database name is mattermost instead of mattermost_test:


    It is saying that Also make sure that the database name is mattermost instead of mattermost_test:
    Where should I have to look out for this, there is no database name in config file

  2. How activate autossl certificatplease ?

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: