Install MySQL database server
Install and set up the database for use by the Mattermost server. You can install either MySQL or PostgreSQL.
Install MySQL on Ubuntu Server 18.04
Log into the server that will host the database, and open a terminal window.
Install MySQL.
sudo apt install mysql-server
Run
mysql_secure_installation
and follow the instructions.
sudo mysql_secure_installation
Log in to MySQL as root.
sudo mysql
Create the Mattermost user ‘mmuser’.
mysql> create user 'mmuser'@'%' identified by 'mmuser-password';
Note
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';
Create the Mattermost database.
mysql> create database mattermost;
Grant access privileges to the user ‘mmuser’.
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 you can use this 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'@'%';
Log out of MySQL.
mysql> exit
Note
If you have installed MySQL on its own server, you need to edit the
/etc/mysql/mysql.conf.d/mysqld.cnf
file and comment out thebind-address = 127.0.0.1
using the#
symbol, then restart your sql server.
With the database installed and the initial setup complete, you can now install the Mattermost server.