the problem with the installation Mattermost server - server

everyone.
OS: Red Hat Enterprise Linux 7
install mattermost v. 5.11.0 instructions https://docs.mattermost.com/install/install-rhel-7.html#installing-postgresql-database
postgresql V. 9.4 on the same server.
file /opt/mattermost/config/config.json
"DriverName": "postgres",
"DataSource": "postgres://mmuser:12345678#localhost:5432/mattermost?sslmode=disable&connect_timeout=10",
file /var/lib/pgsql/9.4/data/pg_hba.conf
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 ident
# IPv6 local connections:
host all all ::1/128 ident
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local replication postgres peer
#host replication postgres 127.0.0.1/32 ident
#host replication postgres ::1/128 ident
during the installation phase of the mattermost server, when you run step 8 "Test the Mattermost server to make sure everything works." after command: sudo -u mattermost ./bin/mattermost
getting an error:
[root#srv-testserver mattermost]# sudo -u mattermost ./bin/mattermost
{"level":"info","ts":1558609830.586414,"caller":"utils/i18n.go:83","msg":"Loaded system translations for 'en' from '/opt/mattermost/i18n/en.json'"}
{"level":"info","ts":1558609830.5868208,"caller":"app/server_app_adapters.go:58","msg":"Server is initializing..."}
{"level":"info","ts":1558609830.5903602,"caller":"sqlstore/supplier.go:224","msg":"Pinging SQL master database"}
{"level":"error","ts":1558609830.6013992,"caller":"sqlstore/supplier.go:236","msg":"Failed to ping DB retrying in 10 seconds err=pq: Ident authentication failed for user \"mmuser\""}
please help advice

Related

Error message with pg_dump and PostgreSQL 14

We use PostgreSQL for our database of Speedy Net. I had a production server with PostgreSQL 13, and I backed up my database with the following command:
pg_dump -U postgres -h localhost "speedy_net" | gzip > <file_name>.sql.gz
It worked with PostgreSQL 13, but recently I upgraded my server to Ubuntu 22.04.1 LTS and PostgreSQL 14. I loaded the database from SQL and everything works properly, but now I can't backup the database - I get the following error message:
pg_dump: error: connection to server at "localhost" (::1), port 5432 failed: fe_sendauth: no password supplied
Now, something has changed in the configuration file from PostgreSQL 13 to 14. In PostgreSQL 13, the file /etc/postgresql/13/main/pg_hba.conf was:
# Database administrative login by Unix domain socket
local all postgres peer
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all peer
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
local replication all peer
host replication all 127.0.0.1/32 md5
host replication all ::1/128 md5
And in PostgreSQL 14 the file /etc/postgresql/14/main/pg_hba.conf is:
# Database administrative login by Unix domain socket
local all postgres peer
local all speedy_net trust
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all peer
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 scram-sha-256
# Allow replication connections from localhost, by a user with the
# replication privilege.
local replication all peer
host replication all 127.0.0.1/32 scram-sha-256
host replication all ::1/128 scram-sha-256
Notice, the line local all speedy_net trust is new. Is this line causing problems? I had to add it because otherwise I couldn't load the database from SQL.
Do you know how I fix it so that backups will work? If I run the command pg_dump -U postgres -h localhost "speedy_net" manually I get prompted for password, but there is no password and it worked with PostgreSQL 13.
Maybe I need to change the password? How do I do it?
The line that is causing the problems in the new file is
host all all ::1/128 scram-sha-256
That requires you to supply a password. You have two choices:
Use a different authentication method. trust would allow you to login without a password (since you are using it with “localhost” in IPv4, why not with IPv6?). If you don't want that, certificate authentication would be an option.
Create a password file on the new machine. Since you forced password authentication on the old machine, that's probably what you used there.

Postgresql sql script execution

I am trying to execute the following on a fresh Postgre started as a service on CentOS 7
psql -h localhost -p 5432 -U postgres -X -d postgres -f /home/user/Documents/test.sql
however i get this error :
psql: FATAL: Ident authentication failed for user "postgres"
my pg_hba.conf is defined as following:
# TYPE DATABASE USER ADDRESS METHOD
#remove-line-for-nolocal## "local" is for Unix domain socket connections only
#remove-line-for-nolocal#local all all #authmethodlocal#
# IPv4 local connections:
local all user peer
local all postgres 127.0.0.1/32 trust
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
#remove-line-for-nolocal#local replication all #authmethodlocal#
host replication all 127.0.0.1/32 #authmethodhost#
host replication all ::1/128 #authmethodhost#
Why does the execution fail ?

psql: error: could not connect to server: FATAL: Peer authentication failed for user "postgres"

i installed and setup postgresql-12 with the commands from here [https://www.postgresql.org/download/linux/redhat/]
yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
yum install postgresql12
yum install postgresql12-server
/usr/pgsql-12/bin/postgresql-12-setup initdb
systemctl enable postgresql-12
systemctl start postgresql-12
i then tried to log into the database
psql postgres postgres
i got the error
psql: error: could not connect to server: FATAL: Peer authentication failed for user "postgres"
there are two pg_hba.conf files on my system. i checked the authentication settings, shown below, as recommended here [psql: FATAL: Ident authentication failed for user "postgres"
/data/pg_data_dir/pg_hba.conf
# TYPE DATABASE USER ADDRESS METHOD
host all all 0.0.0.0/0 md5
# "local" is for Unix domain socket connections only
local all all md5
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust
# Allow replication connections from localhost, by a user with the
# replication privilege.
local replication all trust
host replication all 127.0.0.1/32 trust
host replication all ::1/128 trust
/var/lib/pgsql/12/data/pg_hba.conf
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all md5
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 trust
# Allow replication connections from localhost, by a user with the
# replication privilege.
local replication all trust
host replication all 127.0.0.1/32 trust
host replication all ::1/128 trust
the authentication settings look OK, so i'm not sure what to do from here.
EDIT - To make this more structured and usable.
First, you need to understand what each of those authentification methods mean, there is a ton on infromation in here about this. Long story short, at this stage, the one you'll likely be interested in is md5 which is a hashed password, or trust which is no password.
After installing the postgres on your machine, you'll need to become the postgres user and then attempt psql
~# su -l postgres --assume you're postgres
~$ psql --connect
psql (xx.x ))
Type "help" for help.
postgres=#
Once you're in, you can set a new password for that user:
postgres=# \password postgres
To prevent this from happening, you'll need to ask postgres where the hba file is:
postgres=# SHOW hba_file;
Use your favourite text editor and modify it to fulfill your needs.
Also you need to make sure you reload the postgresql service, the command is:
sudo systemctl reload postgresql-12.service

psql: FATAL: password authentication failed for user "icinga"

I am trying to setup Icinga 2 on CentOS7 and followed instructions as mentioned in the official document. [https://docs.icinga.com/icinga2/latest/doc/module/icinga2/toc#!/icinga2/latest/doc/module/icinga2/chapter/getting-started][1].I have created the database and user as icinga. I am facing the following issue psql: FATAL: password authentication failed for user "icinga" when trying to import the Icinga 2 IDO schema using the below commands
export PGPASSWORD=icinga and psql -U icinga -d icinga < /usr/share/icinga2-ido-pgsql/schema/pgsql.sql
Below is my pg_hba.conf am using
# TYPE DATABASE USER ADDRESS METHOD
# icinga
local icinga icinga md5
host icinga icinga 127.0.0.1/32 md5
host icinga icinga ::1/128 md5
# "local" is for Unix domain socket connections only
local all all peer
# IPv4 local connections:
host all all 127.0.0.1/32 ident
# IPv6 local connections:
host all all ::1/128 ident
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local replication postgres peer
#host replication postgres 127.0.0.1/32 ident
#host replication postgres ::1/128 ident
Try to change
local all all peer
to:
local all all md5
Had this same issue on Ubuntu Bionic, was able to resolve by adding localhost explicitly as the host:
export PGPASSWORD=icinga
psql -U icinga -d icinga -h localhost < /usr/share/icinga2-ido-pgsql/schema/pgsql.sql

pgadmin postgresql - register new local server

I am trying to setup pgAdmin on a new macbook. I am in the process of setting up a local server but keep getting the error:
Error connecting to the server: FATAL: role "postgres" does not exist
Here are my settings:
And here are the contents of my pg_hba.conf file:
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local replication abc1234 trust
#host replication abc1234 127.0.0.1/32 trust
#host replication abc1234 ::1/128 trust
host all all localhost trust
host all all 192.168.1.0/24 trust
Can someone help?
Thanks in advance!
This error message is telling you that the postgres role, which is the usual "superuser" in a postgresql installation, does not exist.
In this case, it seems that the cluster has been installed using a local user as the superuser:
$ ls -ld /usr/local/var/postgres
drwx------ 30 abc1234 admin 1020 May 29 20:46 /usr/local/var/postgres
In which case we can probably login using:
$ psql -U abc1234 postgres