A SlackBuild for building and installing PostgreSQL can be found at SlackBuilds.org; follow the instructions there, and install PostgreSQL. After installing PostgreSQL perform the following steps:
su postgres -c "initdb -D /var/lib/pgsql/10.2/data --locale=en_US.UTF-8 -A md5 -W"
/etc/rc.d/rc.postgresql start
su -l postgres
psql
CREATE DATABASE mattermostdb;
CREATE USER mattermost;
GRANT ALL PRIVILEGES ON DATABASE mattermostdb to mattermost;
# "local" is for Unix domain socket connections only
local all all md5
with
local mattermostdb mattermost peer
echo "mattermap mattermostdb mattermost" >> /var/lib/pgsql/10.2/data/pg_ident.conf
exit
/etc/rc.d/rc.postgresql restart
useradd --system --user-group mattermost
sudo -u mattermost psql --dbname=mattermostdb --username=mattermost