I think I am unable to relock my postgres psql account The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) Come Celebrate our 10 Year Anniversary!Cannot change password for user postgres in postgresqlpsql empty database before restorePSQL error with restarting postgres in SSLCannot access psql after installing postgrespsql editor setting on UbuntuPSQL 64bit driver errorPostgres roles best practice implementationpg_dump: [archiver (db)] connection to database failed: FATAL: Peer authentication failed for user “postgres”PostgreSQL password issue with psqlparallize postgres queries with bash and psql?
The variadic template constructor of my class cannot modify my class members, why is that so?
Match Roman Numerals
How does ice melt when immersed in water
Can the DM override racial traits?
Windows 10: How to Lock (not sleep) laptop on lid close?
How is simplicity better than precision and clarity in prose?
Is it ok to offer lower paid work as a trial period before negotiating for a full-time job?
Difference between "generating set" and free product?
Create an outline of font
Who or what is the being for whom Being is a question for Heidegger?
Derivation tree not rendering
Why is superheterodyning better than direct conversion?
Is every episode of "Where are my Pants?" identical?
Simulating Exploding Dice
Semisimplicity of the category of coherent sheaves?
how can a perfect fourth interval be considered either consonant or dissonant?
Python - Fishing Simulator
Change bounding box of math glyphs in LuaTeX
Grover's algorithm - DES circuit as oracle?
Arduino Pro Micro - switch off LEDs
Why not take a picture of a closer black hole?
Didn't get enough time to take a Coding Test - what to do now?
Is above average number of years spent on PhD considered a red flag in future academia or industry positions?
Can withdrawing asylum be illegal?
I think I am unable to relock my postgres psql account
The 2019 Stack Overflow Developer Survey Results Are In
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
Come Celebrate our 10 Year Anniversary!Cannot change password for user postgres in postgresqlpsql empty database before restorePSQL error with restarting postgres in SSLCannot access psql after installing postgrespsql editor setting on UbuntuPSQL 64bit driver errorPostgres roles best practice implementationpg_dump: [archiver (db)] connection to database failed: FATAL: Peer authentication failed for user “postgres”PostgreSQL password issue with psqlparallize postgres queries with bash and psql?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
When I was setting up postgresql on linux, I was following a tutorial that I think had me change the postgres account password and I did not know any better. Please forgive my ignorance.
When I type "psql postgres" it asks for a password and only one password works. I have tried following previous answers by implementing "sudo passwd --lock postgres" and "sudo -u postgres psql postgres" with "password postgres" and setting a new password (which does not work).
I am afraid to edit /etc/passwd and put * instead of the password because that comment has very few upvotes and I don't know what it will actually do.
Everything I try (even changing md5 to trust in pg_hba.conf), after I enter "sudo /etc/init.d/postgresql restart", psql postgres STILL REQUIRES a password and it only accepts the one password that works. Anything else returns 'psql: FATAL: password authentication failed'.
What can I do?
password ubuntu-18.04 psql
New contributor
Humble-Data-22 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
When I was setting up postgresql on linux, I was following a tutorial that I think had me change the postgres account password and I did not know any better. Please forgive my ignorance.
When I type "psql postgres" it asks for a password and only one password works. I have tried following previous answers by implementing "sudo passwd --lock postgres" and "sudo -u postgres psql postgres" with "password postgres" and setting a new password (which does not work).
I am afraid to edit /etc/passwd and put * instead of the password because that comment has very few upvotes and I don't know what it will actually do.
Everything I try (even changing md5 to trust in pg_hba.conf), after I enter "sudo /etc/init.d/postgresql restart", psql postgres STILL REQUIRES a password and it only accepts the one password that works. Anything else returns 'psql: FATAL: password authentication failed'.
What can I do?
password ubuntu-18.04 psql
New contributor
Humble-Data-22 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
When I was setting up postgresql on linux, I was following a tutorial that I think had me change the postgres account password and I did not know any better. Please forgive my ignorance.
When I type "psql postgres" it asks for a password and only one password works. I have tried following previous answers by implementing "sudo passwd --lock postgres" and "sudo -u postgres psql postgres" with "password postgres" and setting a new password (which does not work).
I am afraid to edit /etc/passwd and put * instead of the password because that comment has very few upvotes and I don't know what it will actually do.
Everything I try (even changing md5 to trust in pg_hba.conf), after I enter "sudo /etc/init.d/postgresql restart", psql postgres STILL REQUIRES a password and it only accepts the one password that works. Anything else returns 'psql: FATAL: password authentication failed'.
What can I do?
password ubuntu-18.04 psql
New contributor
Humble-Data-22 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
When I was setting up postgresql on linux, I was following a tutorial that I think had me change the postgres account password and I did not know any better. Please forgive my ignorance.
When I type "psql postgres" it asks for a password and only one password works. I have tried following previous answers by implementing "sudo passwd --lock postgres" and "sudo -u postgres psql postgres" with "password postgres" and setting a new password (which does not work).
I am afraid to edit /etc/passwd and put * instead of the password because that comment has very few upvotes and I don't know what it will actually do.
Everything I try (even changing md5 to trust in pg_hba.conf), after I enter "sudo /etc/init.d/postgresql restart", psql postgres STILL REQUIRES a password and it only accepts the one password that works. Anything else returns 'psql: FATAL: password authentication failed'.
What can I do?
password ubuntu-18.04 psql
password ubuntu-18.04 psql
New contributor
Humble-Data-22 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Humble-Data-22 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Humble-Data-22 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked Apr 9 at 3:53
Humble-Data-22Humble-Data-22
31
31
New contributor
Humble-Data-22 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Humble-Data-22 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Humble-Data-22 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Authentication method "peer"
If your authentication method is peer like
local all postgres peer
and/or
local all all peer
in pg_hba.conf, then connect as linux user postgres to the database.
sudo -u postgres psql
You won't need a password, even if set.
Note: psql -U postgres postgres run as a different linux user as postgres does not work in this case and fails with psql: FATAL: Peer authentication failed for user "postgres".
Authentication method "md5"
If your authentication method is md5, then you will need the correct password to connect.
Reset password
Comment all existing lines starting with "local" in
pg_hba.confand add linelocal all postgres trustRestart postgres
service postgresql restartConnect to database
# as any linux user
psql -U postgres
# or as user postgres
sudo -u postgres psqlChange password
ALTER USER postgres WITH PASSWORD 'password';Exit
qRestore your changes in
pg_hba.conf, default for postgresql 9.6 on Debian 9.8.0 is# 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 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 peer
#host replication postgres 127.0.0.1/32 md5
#host replication postgres ::1/128 md5Restart postgres
service postgresql restart
Note 2:
If you want to change the password for a host record, then do the same as above by using method trust and connect with the hostname option using psql -U postgres -h localhost postgres.
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "2"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Humble-Data-22 is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f962127%2fi-think-i-am-unable-to-relock-my-postgres-psql-account%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Authentication method "peer"
If your authentication method is peer like
local all postgres peer
and/or
local all all peer
in pg_hba.conf, then connect as linux user postgres to the database.
sudo -u postgres psql
You won't need a password, even if set.
Note: psql -U postgres postgres run as a different linux user as postgres does not work in this case and fails with psql: FATAL: Peer authentication failed for user "postgres".
Authentication method "md5"
If your authentication method is md5, then you will need the correct password to connect.
Reset password
Comment all existing lines starting with "local" in
pg_hba.confand add linelocal all postgres trustRestart postgres
service postgresql restartConnect to database
# as any linux user
psql -U postgres
# or as user postgres
sudo -u postgres psqlChange password
ALTER USER postgres WITH PASSWORD 'password';Exit
qRestore your changes in
pg_hba.conf, default for postgresql 9.6 on Debian 9.8.0 is# 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 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 peer
#host replication postgres 127.0.0.1/32 md5
#host replication postgres ::1/128 md5Restart postgres
service postgresql restart
Note 2:
If you want to change the password for a host record, then do the same as above by using method trust and connect with the hostname option using psql -U postgres -h localhost postgres.
add a comment |
Authentication method "peer"
If your authentication method is peer like
local all postgres peer
and/or
local all all peer
in pg_hba.conf, then connect as linux user postgres to the database.
sudo -u postgres psql
You won't need a password, even if set.
Note: psql -U postgres postgres run as a different linux user as postgres does not work in this case and fails with psql: FATAL: Peer authentication failed for user "postgres".
Authentication method "md5"
If your authentication method is md5, then you will need the correct password to connect.
Reset password
Comment all existing lines starting with "local" in
pg_hba.confand add linelocal all postgres trustRestart postgres
service postgresql restartConnect to database
# as any linux user
psql -U postgres
# or as user postgres
sudo -u postgres psqlChange password
ALTER USER postgres WITH PASSWORD 'password';Exit
qRestore your changes in
pg_hba.conf, default for postgresql 9.6 on Debian 9.8.0 is# 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 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 peer
#host replication postgres 127.0.0.1/32 md5
#host replication postgres ::1/128 md5Restart postgres
service postgresql restart
Note 2:
If you want to change the password for a host record, then do the same as above by using method trust and connect with the hostname option using psql -U postgres -h localhost postgres.
add a comment |
Authentication method "peer"
If your authentication method is peer like
local all postgres peer
and/or
local all all peer
in pg_hba.conf, then connect as linux user postgres to the database.
sudo -u postgres psql
You won't need a password, even if set.
Note: psql -U postgres postgres run as a different linux user as postgres does not work in this case and fails with psql: FATAL: Peer authentication failed for user "postgres".
Authentication method "md5"
If your authentication method is md5, then you will need the correct password to connect.
Reset password
Comment all existing lines starting with "local" in
pg_hba.confand add linelocal all postgres trustRestart postgres
service postgresql restartConnect to database
# as any linux user
psql -U postgres
# or as user postgres
sudo -u postgres psqlChange password
ALTER USER postgres WITH PASSWORD 'password';Exit
qRestore your changes in
pg_hba.conf, default for postgresql 9.6 on Debian 9.8.0 is# 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 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 peer
#host replication postgres 127.0.0.1/32 md5
#host replication postgres ::1/128 md5Restart postgres
service postgresql restart
Note 2:
If you want to change the password for a host record, then do the same as above by using method trust and connect with the hostname option using psql -U postgres -h localhost postgres.
Authentication method "peer"
If your authentication method is peer like
local all postgres peer
and/or
local all all peer
in pg_hba.conf, then connect as linux user postgres to the database.
sudo -u postgres psql
You won't need a password, even if set.
Note: psql -U postgres postgres run as a different linux user as postgres does not work in this case and fails with psql: FATAL: Peer authentication failed for user "postgres".
Authentication method "md5"
If your authentication method is md5, then you will need the correct password to connect.
Reset password
Comment all existing lines starting with "local" in
pg_hba.confand add linelocal all postgres trustRestart postgres
service postgresql restartConnect to database
# as any linux user
psql -U postgres
# or as user postgres
sudo -u postgres psqlChange password
ALTER USER postgres WITH PASSWORD 'password';Exit
qRestore your changes in
pg_hba.conf, default for postgresql 9.6 on Debian 9.8.0 is# 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 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 peer
#host replication postgres 127.0.0.1/32 md5
#host replication postgres ::1/128 md5Restart postgres
service postgresql restart
Note 2:
If you want to change the password for a host record, then do the same as above by using method trust and connect with the hostname option using psql -U postgres -h localhost postgres.
answered Apr 9 at 8:24
FreddyFreddy
79119
79119
add a comment |
add a comment |
Humble-Data-22 is a new contributor. Be nice, and check out our Code of Conduct.
Humble-Data-22 is a new contributor. Be nice, and check out our Code of Conduct.
Humble-Data-22 is a new contributor. Be nice, and check out our Code of Conduct.
Humble-Data-22 is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Server Fault!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f962127%2fi-think-i-am-unable-to-relock-my-postgres-psql-account%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown