postgresql and pgadming4 error on connecting to db server - postgresql

I have installed postgresql database and pgadmin4 on my fedora machine.
after starting the postgresql service and trying to connect to postgresql server
from pgadmin4
i am getting this error
Unable to connect to server:
FATAL: Ident authentication failed for user "postgres".
how should i fix this?

Did you create the "postgres" user while installing? You may be using wrong credentials, if you have forgotten the password, please change the pg_hba.conf (then reload or restart postgresql server) to allow all the connections from local without credentials, then change the password for postgres (again reload or restart postgresql) user. Change the pg_hba.conf to use credentials and try logging in.

Related

pgAdmin4 can not connect to postgres server though the password is correct?

I am newbie with pgAdmin4 and here is my problem.
I setup postgresql in ubuntu, everything seems ok, I change password for the account postgres by this command sudo passwd postgres and note it very carefully.
Then, I tried to connect to postgresql by pgAdmin4 follow this tutorial.
https://www.youtube.com/watch?v=XRdl0P4V-PU
Name is localhost
Hostname is localhost
Port is 5432
Maintenance database is postgres
Username is postgres
And password is the password I set above.
But they said to me that Unable to connect to server: FATAL: password authentication failed for user "postgres"
I tried to change the password, but still the same error. Seems something wrong ?
Could you please give me some ideas ? Thank you very much.
It seems like you only changed the password at the OS level. Basically, for the Ubuntu user postgres, you changed the password with sudo passwd postgres.
In order to change the password for the postgres user for the database, you need to log into the database and change the postgres user's password with ALTER ROLE postgres PASSWORD '<your password>';
In order to accomplish this, you will need to change your pg_hba.conf temporarily, allowing the postgres user to log in without a password (either set to trust or peer authentication method, change the password, and the switch back to password or other authentication method). After changing pg_hba.conf you will either want to issue a kill HUP to the parent postgres process (check the top-most process in your ps -ef | grep postgres output), or simply restart postgres with systemctl restart postgresql<your_postgres_version>

PostgreSQL: FATAL: password authentication failed for user "postgres"

I have a ThingsBoard Professional Edition setup using AWS EC2 instance. The database is PostgreSQL-12. I tend to get the following error: FATAL: password authentication failed for user "postgres" FATAL: password authentication failed for user "postgres" when trying to log into the remote database server on pgAdmin4.
Here is a screenshot of the error shown when attempting to log in to server created on pgAdmin4.
Here is how I configured the remote database server (where Host name/address is the Public IPv4 of my EC2 instance).
In postgresql.conf, I have replaced the line listen_address='127.0.0.1' with listen_addresses='*'.
In pg_hba.conf, I added host all all 0.0.0.0/0 md5.
Here is a screenshot of my pg_hba.conf file:
I have also set the password for the user 'postgres' using the psql command #\password.
Here is what is shown in thingboard.log when I run the command:
cat /var/log/thingsboard/thingsboard.log | grep ERROR
Partial screenshot of /var/log/postgresql/postgresql-12-main.log shows the following:
I constantly have to use #ALTER USER postgres PASSWORD ‘<password>’; to be able to overcome this error but the error tends to return when I restart my local Windows machine.
That must be done by some software other than PostgreSQL.
Configure logging by setting log_statement = 'ddl' in postgresql.conf and restarting the database. Then you can more easily figure out when and by which software your password gets changed.
Additionally, configure pg_hba.conf to not allow passwordless connections from anywhere, then change the password. You may see some component start to complain - that component may be at fault.

Unable to connect to server: FATAL: role "postgres" does not exist

I just did a fresh installation of postgres 13 on my windows 10 64 bit and when I open the pgadmin 4 there are not servers listed on the servers list on left handside. When I try to add a server I get Unable to connect to server: FATAL: role "postgres" does not exist
the credentials I am using here are the credentials I entered while installing postgres but I have tried a bunch of other creds as well like postgres and blank, postgres and postgres but the behavior is same.
In my pg_hba.conf file the value of method is already set to trust instead of md5 so I have not made any changes to that file. I have tried restarting the postgres service as well but that didnt help.
Any help would be appreciated.

How to run postgresql from Command line and know available Databases in Windows

I am very new to postgreSQL and struggling to create a connection in my Eclipese.
Here is what I have done till now:
Installed DBeaver plugin for eclipse from marketplace.
Installed PostgreSQL version 10 from https://www.postgresql.org/download/windows/
Now I attempt to create a connection in Eclipse but I get an error "FATAL: password authentication failed for user "testuser"
I checked through a similar thread (
Getting authentication failed error with postgresql from command line
) but could not resolve the issue.
Could you please help.
To connect the PostgreSQL via Command line you have to install a PostgreSQL provided tool called "psql" if not installed already.
Then use the below command to connect to PostgreSQL database.
psql -h localhost -p 5432 -U postgres
Explanation:
localhost: is the hostname of machine where PostgreSQL is installed.
5432 : is the default PostgreSQL port
postgres : is the username of to connect to DB
Solution for your issue:
FATAL: password authentication failed for user "testuser"
As error message specified, either user not exists on database or the password that you supplied to connect is incorrect. Re-verify your user and password, and try again.
All the best.

bucardo unable to connect to other DBs

I experience some problems using bucardo add db command. It looks like it's unable to connect to other postgreSQL databases.
I tried to do it in several ways. With pg_hba.conf setting
"local" is for Unix domain socket connections only:
local all postgres ident
/usr/local/src/bucardo-5.3.1# ./bucardo add db cd_db dbname=hq
Connection to "cd_db" (PostgreSQL database) as user bucardo failed. You may force add it with the --force argument.
Error was: fe_sendauth: no password supplied
Then with pg_hba.conf setting
"local" is for Unix domain socket connections only:
local all all peer
with postgres credentials:
/usr/local/src/bucardo-5.3.1# ./bucardo add db cd_db dbname=hq db dbuser=postgres
Connection to "cd_db" (PostgreSQL database) as user postgres failed. You may force add it with the --force argument.
Error was: FATAL: Peer authentication failed for user "postgres"
with bucardo credentials:
/usr/local/src/bucardo-5.3.1# ./bucardo add db cd_db dbname=hq db dbuser=bucardo dbpass=bucardo-runner
Connection to "cd_db" (PostgreSQL database) as user bucardo failed.
Error was: FATAL: Peer authentication failed for user "bucardo"
Please help me to figure out what is wrong and how to use the installed bucardo.
I'm running it on Linux Debian, just for reference.
To use ident to login with a different user other than the linux user you will need to map the user in pg_ident.conf.
pg_indet.conf
app root postgres
app root bucardo
app {username} bucardo
pg_hba.conf
local all all ident map=app