diff --git a/source/install/prepare-mattermost-database.rst b/source/install/prepare-mattermost-database.rst index 5112e811426..a03b05f77e3 100644 --- a/source/install/prepare-mattermost-database.rst +++ b/source/install/prepare-mattermost-database.rst @@ -16,158 +16,158 @@ To set up a PostgreSQL database for use by the Mattermost server: 2. Access PostgreSQL by running: - .. code-block:: sh +.. code-block:: sh - sudo -u postgres psql + sudo -u postgres psql 3. Create the Mattermost database by running: - .. tab:: Ubuntu +.. tab:: Ubuntu - .. code-block:: SQL + .. code-block:: SQL - CREATE DATABASE mattermost; + CREATE DATABASE mattermost; - .. tab:: Red Hat +.. tab:: Red Hat - .. code-block:: SQL + .. code-block:: SQL - CREATE DATABASE mattermost WITH ENCODING 'UTF8' LC_COLLATE='en_US.UTF-8' LC_CTYPE='en_US.UTF-8' TEMPLATE=template0; + CREATE DATABASE mattermost WITH ENCODING 'UTF8' LC_COLLATE='en_US.UTF-8' LC_CTYPE='en_US.UTF-8' TEMPLATE=template0; 4. Create the Mattermost user *mmuser* by running the following command. Ensure you use a password that's more secure than ``mmuser-password``. - .. code-block:: SQL +.. code-block:: SQL - CREATE USER mmuser WITH PASSWORD 'mmuser-password'; + CREATE USER mmuser WITH PASSWORD 'mmuser-password'; 5. If you're configuring PostgreSQL v15.x or later: - a. Grant the user access to the Mattermost database by running: +a. Grant the user access to the Mattermost database by running: - .. code-block:: SQL +.. code-block:: SQL - GRANT ALL PRIVILEGES ON DATABASE mattermost to mmuser; - + GRANT ALL PRIVILEGES ON DATABASE mattermost to mmuser; + - b. Grant the user to change the owner of a database to a user ``mmuser`` by running: +b. Grant the user to change the owner of a database to a user ``mmuser`` by running: - .. code-block:: SQL +.. code-block:: SQL - ALTER DATABASE mattermost OWNER TO mmuser; + ALTER DATABASE mattermost OWNER TO mmuser; - c. Grant access to objects contained in the specified schema by running: +c. Grant access to objects contained in the specified schema by running: - .. code-block:: SQL +.. code-block:: SQL - GRANT USAGE, CREATE ON SCHEMA PUBLIC TO mmuser; + GRANT USAGE, CREATE ON SCHEMA PUBLIC TO mmuser; 6. Exit the PostgreSQL interactive terminal by running: - .. code-block:: text +.. code-block:: text - \q + \q 7. (Optional) If you use separate servers for your database and the Mattermost server, you may allow PostgreSQL to listen on all assigned IP addresses. We recommend ensuring that only the Mattermost server is able to connect to the PostgreSQL port using a firewall. - .. tab:: Ubuntu +.. tab:: Ubuntu - Open ``/etc/postgresql/{version}/main/postgresql.conf`` as *root* in a text editor. - - Replace ``{version}`` with the version of PostgreSQL that's currently running. + Open ``/etc/postgresql/{version}/main/postgresql.conf`` as *root* in a text editor. + + Replace ``{version}`` with the version of PostgreSQL that's currently running. - a. Find the following line: ``#listen_addresses = 'localhost'`` + a. Find the following line: ``#listen_addresses = 'localhost'`` - b. Uncomment the line and change ``localhost`` to ``*``: ``listen_addresses = '*'`` + b. Uncomment the line and change ``localhost`` to ``*``: ``listen_addresses = '*'`` - c. Restart PostgreSQL for the change to take effect by running: + c. Restart PostgreSQL for the change to take effect by running: - .. code-block:: sh + .. code-block:: sh - sudo systemctl restart postgresql-{version} + sudo systemctl restart postgresql-{version} - .. tab:: Red Hat +.. tab:: Red Hat - Open ``/var/lib/pgsql/{version}/data/postgresql.conf`` as *root* in a text editor. + Open ``/var/lib/pgsql/{version}/data/postgresql.conf`` as *root* in a text editor. - Replace ``{version}`` with the version of PostgreSQL that's currently running. + Replace ``{version}`` with the version of PostgreSQL that's currently running. - a. Find the following line: ``#listen_addresses = 'localhost'`` + a. Find the following line: ``#listen_addresses = 'localhost'`` - b. Uncomment the line and change ``localhost`` to ``*``: ``listen_addresses = '*'`` + b. Uncomment the line and change ``localhost`` to ``*``: ``listen_addresses = '*'`` - c. Restart PostgreSQL for the change to take effect by running: + c. Restart PostgreSQL for the change to take effect by running: - .. code-block:: sh + .. code-block:: sh - sudo systemctl restart postgresql-{version} + sudo systemctl restart postgresql-{version} 8. Modify the file ``pg_hba.conf`` to allow the Mattermost server to communicate with the database by ensuring host connection types are set to ``trust``. - .. tab:: Ubuntu +.. tab:: Ubuntu - These host connections are specific to Ubuntu 20.04, and will differ depending on the operating system version you're running. For example, in Ubuntu 22.04, the ``peer`` connection types are listed as ``sha-256`` instead. + These host connections are specific to Ubuntu 20.04, and will differ depending on the operating system version you're running. For example, in Ubuntu 22.04, the ``peer`` connection types are listed as ``sha-256`` instead. - **Local Database (same server)** + **Local Database (same server)** - If the Mattermost server and the database are on the same machine: + If the Mattermost server and the database are on the same machine: - a. Open ``/etc/postgresql/{version}/main/pg_hba.conf`` as *root* in a text editor. + a. Open ``/etc/postgresql/{version}/main/pg_hba.conf`` as *root* in a text editor. - b. Find the following lines: + b. Find the following lines: - ``local all all peer`` + ``local all all peer`` - ``host all all ::1/128 ident`` + ``host all all ::1/128 ident`` - c. Change ``peer`` and ``ident`` to ``trust``: + c. Change ``peer`` and ``ident`` to ``trust``: - ``local all all trust`` + ``local all all trust`` - ``host all all ::1/128 trust`` + ``host all all ::1/128 trust`` - **Remote Database (separate server)** + **Remote Database (separate server)** - If the Mattermost server and the database are on different machines: + If the Mattermost server and the database are on different machines: - a. Open ``/etc/postgresql/{version}/main/pg_hba.conf`` in a text editor as *root* user. + a. Open ``/etc/postgresql/{version}/main/pg_hba.conf`` in a text editor as *root* user. - b. Add the following line to the end of the file, where ``{mattermost-server-IP}`` is the IP address of the Mattermost server: ``host all all {mattermost-server-IP}/32 md5``. + b. Add the following line to the end of the file, where ``{mattermost-server-IP}`` is the IP address of the Mattermost server: ``host all all {mattermost-server-IP}/32 md5``. - .. tab:: Red Hat +.. tab:: Red Hat - These host connections are specific to Red Hat 8, and will differ depending on the operating system version you're running. + These host connections are specific to Red Hat 8, and will differ depending on the operating system version you're running. - **Local Database (same server)** + **Local Database (same server)** - If the Mattermost server and the database are on the same machine: + If the Mattermost server and the database are on the same machine: - a. Open ``/var/lib/pgsql/{version}/data/pg_hba.conf`` as *root* in a text editor. + a. Open ``/var/lib/pgsql/{version}/data/pg_hba.conf`` as *root* in a text editor. - b. Find the following lines: + b. Find the following lines: - ``local all all peer`` + ``local all all peer`` - ``host all all ::1/128 scram-sha-256`` + ``host all all ::1/128 scram-sha-256`` - c. Change ``peer`` and ``ident`` to ``trust``: + c. Change ``peer`` and ``ident`` to ``trust``: - ``local all all trust`` + ``local all all trust`` - ``host all all ::1/128 trust`` + ``host all all ::1/128 trust`` - **Remote Database (separate server)** + **Remote Database (separate server)** - If the Mattermost server and the database are on different machines: + If the Mattermost server and the database are on different machines: - a. Open ```/var/lib/pgsql/{version}/data/pg_hba.conf`` in a text editor as *root* user. + a. Open ```/var/lib/pgsql/{version}/data/pg_hba.conf`` in a text editor as *root* user. - b. Add the following line to the end of the file, where ``{mattermost-server-IP}`` is the IP address of the Mattermost server: ``host all all {mattermost-server-IP}/32 md5``. + b. Add the following line to the end of the file, where ``{mattermost-server-IP}`` is the IP address of the Mattermost server: ``host all all {mattermost-server-IP}/32 md5``. 9. Reload PostgreSQL by running: - .. code-block:: sh +.. code-block:: sh - sudo systemctl reload postgresql-{version} + sudo systemctl reload postgresql-{version} 10. Verify that you can connect with the user *mmuser*. @@ -175,17 +175,17 @@ To set up a PostgreSQL database for use by the Mattermost server: If the Mattermost server and the database are on the same machine, use the following command: - .. code-block:: sh + .. code-block:: sh - psql --dbname=mattermost --username=mmuser --password + psql --dbname=mattermost --username=mmuser --password .. tab:: Remote Database (separate server) If the Mattermost server is on a different machine, log into that machine and use the following command: - .. code-block:: sh + .. code-block:: sh - psql --host={postgres-server-IP} --dbname=mattermost --username=mmuser --password + psql --host={postgres-server-IP} --dbname=mattermost --username=mmuser --password .. note::