I've installed PostgreSQL 9.1 and pgadmin3 on Ubuntu Server 13.10.
I configured postgresql.conf with: listen_addresses = '*'
also I configured ph_hba.conf by changed peer connections to md5
Plus I reset the password of postgres by: sudo password postgres
then restarted the service with sudo /etc/init.d/postgresql restart
after that I tried to connect to the default PostgreSQL template database:
sudo -u postgres psql template1
but login failed with this error message:
psql: FATAL: password authentication failed for user "postgres"
then I tried to login from the pgadmin, which gave me the same error.
I've read here that it might be a password expiry dates bug
PostgreSQL user can not connect to server after changing password
but I couldn't solve it coz I cannot login with psql. Does anyone now how to resolve this issue?
EDIT
ph_hba file:
local all postgres md5
local all all md5
local all all trust
host all all 127.0.0.1/32 md5
hostssl all all 192.168.0.0/16 trust
host all all 192.168.0.0/16 trust
host all all ::1/128 md5
in your pg_hba.conf, modify
local all postgres md5
to
local all postgres trust
then you'll be able to login without password
Related
I'm completely unable to access anything in postgres as it's asking for a password for both the default postgres user as well as my mac username. I don't have a password for either, and in the case of postgres I don't even understand why there is a password as by defualt it shouldn't have one.
After running through many other answers on the subject:
If I run psql:
$ psql
Password for user <MY_USERNAME>:
psql: error: could not connect to server: FATAL: password authentication failed for user "<MY_USERNAME>"
If I run it with sudo:
$ sudo psql
Password for user root:
psql: error: could not connect to server: FATAL: password authentication failed for user "root"
If I run it with postgres user:
$ sudo -u postgres psql
Password for user postgres:
psql: error: could not connect to server: FATAL: password authentication failed for user "postgres"
Also in my pg_hba.conf all the methods are set to trust, have also tried changing to ident and md5.
On the advice of #jjanes I searched for other pg_hba.conf files and this is what I found:
/usr/local/var/postgres.old/pg_hba.conf
/usr/local/var/postgres/pg_hba.conf
/usr/local/var/postgresql#10/pg_hba.conf
/Library/PostgreSQL/12/data/pg_hba.conf
The last one is empty (and read only) and the other three all look like this:
# 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 all trust
host replication all 127.0.0.1/32 trust
host replication all ::1/128 trust
Anyone have any advice?
I had a similar issue on my Ubuntu 21.10.
I also tried resolving the problem by following the steps suggested above, but none worked.
At last, I resolved the problem by uninstalling postgres and removing every related files: https://askubuntu.com/questions/32730/how-to-remove-postgres-from-my-installation/32735#32735
Thereafter, I did a new installation of postgres using: https://levelup.gitconnected.com/installing-and-configuring-postgresql-on-ubuntu-20-04-e50122635927
Now, everything works fine.
Cheers.
I'm pulling my hair out trying to figure out what is wrong.
I am attempting to connect to a local install of postgres 11 on ubuntu 19.
sudo -u postgres psql gives me full access to the psql shell as user postgres. I created a new user and db, granted permissions, set a password, edited the pg_hba.conf file, and restarted the server. I have also ensured that my password is not expired.
Now I expect psql "host=localhost user=marcos port=5433 dbname=reddit sslmode=require" to connect to my database, but I get a password error: "psql: FATAL: password authentication failed for user". I know the password I typed is correct, so what is wrong?
Here are the relevant pg_hba.conf lines:
# 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 md5
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# 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
# custom rules
host all marcos all md5
follow this step for ubuntu/linxs
-> sudo -u postgres psql
-> postgres=#
After that right
->postgres=# \password
Enter new password for user “postgres”:
Enter it again:
Now check, the new password is working successfully.
Maybe something is wrong with your old password, try this:
ALTER ROLE marcos WITH ENCRYPTED PASSWORD '<new_password>';
And then connect to your DB with this password.
I recently downloaded the graphical install for postgresql 9.4 on my mac and went through the entire setup, even made a password, but when it came to activate the shell no password would work. I tried my system password and the one I set but neither worked.
Everytime I try
sudo -u postgres psql
I get the error
psql: FATAL: password authentication failed for user "postgres"
This is my pg_hba.conf file
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 md5
Allow replication connections from localhost, by a user with the
replication privilege.
local replication postgres md5
host replication postgres 127.0.0.1/32 md5
Try changing your psql password
Change local in conf file to: local all all trust
Restart psql server: sudo /etc/init.d/postgresql restart
Connect as superuser postgres: sudo -u postgres psql
Change password: ALTER USER postgres PASSWORD 'newpassword';
Change back your conf file to:
local all all md5
Restart psql server: sudo /etc/init.d/postgresql restart
I just installed PostgreSQL 9.2 server on an EC2 AMI instance. However I am not able to connect to it from the command prompt.
Moreover I see two directories in /var/lib: pgsql9 and pgsql92. The data directory in pgsql92 is empty and hence it looks like pgsql9 is the one that is getting used.
[root#ip-172-31-56-103 etc]# psql
Password:
psql: FATAL: password authentication failed for user "root"
[root#ip-172-31-56-103 etc]# sudo su - postgres
-bash-4.2$ psql
Password:
psql: FATAL: password authentication failed for user "postgres"
-bash-4.2$ psql -U postgres
Password for user postgres:
psql: FATAL: password authentication failed for user "postgres"
-bash-4.2$
pg_hba.conf
# "local" is for Unix domain socket connections only
local all all md5
# IPv4 local connections:
host all all 127.0.0.1/32 md5
host all all 0.0.0.0/0 md5
# 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
postgresql.conf
listen_addresses = '*'
To work out which PG install you are using: ps -ef | grep pgsql. You will see for sure which binary, data directory and conf file is being used to give you some comfort.
Have you changed the pg_hba.conf from the default? If so, did you reload it? Something like sudo service postgresql reload should do it, depending upon your OS.
You might want to change the IPv6 local connection to use md5 as well.
Try adding -h localhost or -h 127.0.0.1 to your psql command: e.g. psql -h localhost -U postgres.
Check your postgres password to be doubly / triply sure.
Otherwise, check out the specific docs for your OSs installation. Sometimes apt or yum repos do some additional security configuration for you.
Finally, worst case, change all the pg_hba.conf auth methods to trust, then restart the database, logon, change the postgres password, logout, change the auth methods to md5, reload and try to logon again.
I have recently installed postgresql 9.1 and pgadmin3. But I can't connect to server which I created with this config:
name: mydb
host: 127.0.0.1
port: 5432
service:
Maintenance DB: postgres
username: postgres
password: *
According to similar problems I've set my /etc/postgresql/9.1/main/pg_hba.conf file under ubuntu 12.04 LTS like this:
local all postgres md5
# 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 md5
host all all localhost trust
But when I want to connect to the server I get this error:
Error connecting to the server: FATAL: password authentication failed for user "postgres"
FATAL: password authentication failed for user "postgres"
That was simple after installation of postgresql i should change the postgres user password
and my failure was because of that. The password can simply change through this commands under ubuntu 12.04 LTS:
sudo -u postgres psql
And then in psql:
\password
Now enter the new password and re-enter it.
That's OK! then you can simply sign in.
This way there is no need to change the configuration of pg_hba.conf file.
In fact i failed to login because of my invalid password!
Seems your DB is configured for "postgres" user and PgAdmin is trying to connect as "postgre" (without s in the end).