Thread: new install, can't use - need password for postgres user

new install, can't use - need password for postgres user

From
Douglas Hyde
Date:
I have just completed a first installation on Windows 2008 Server. I was very keen to work with PostGreSQL. I can't
evendo the basic things in pgAdmin III that I installed with the database, as I don't have a password and the
documentationdoesn't provide one. All that is mentioned in my digging is changing the pg_hba.conf file, but no details
onhow  - the manual says: 

"19.1. The pg_hba.conf file
Client authentication is controlled by a configuration file, which traditionally is named pg_hba.conf and is stored in
thedatabase cluster's data directory. (HBA stands for host-based authentication.) A default pg_hba.conf file is
installedwhen the data directory is initialized by initdb. It is possible to place the authentication configuration
fileelsewhere, however; see the hba_file configuration parameter...Each record specifies a connection type, a client IP
addressrange (if relevant for the connection type), a database name, a user name, and the authentication method to be
usedfor connections matching these parameters. The first record with a matching connection type, client address,
requesteddatabase, and user name is used to perform authentication. There is no "fall-through" or "backup": if one
recordis chosen and the authentication fails, subsequent records are not considered. If no record matches, access is
denied."

These instructions do not seem to be about the password for an individual users, but rather the instructions to allow
clientsand users associated with clients to be allowed access - pgAdmin is one of those?  Knowing it probably wouldn't
work,I tried to edit that file, adding localhost and all users (followed guidance in the manual) and then PostGreSQL
wouldn'trestart. When I run pgAdmin, it presents me a password challenge, so that client seems to be connected to the
server.There are several command line references to add new accounts, but they use unix commands (do those work in
windows,and how do I get to command line in windows) and they also seem to require a user. So I have no password, don't
knowhow to add one, or add a new user, and now have no documentation on what to do. Why wouldn't pgAdmin know the
defaultpassword for the user "postgres" - I am not stupid, at least I don't think so, and would know to change that
rightaway. I am now having my doubts about postgreSQL, as someone really should make this much simpler - starting off
onthe wrong foot.  

Bottom line, how do I add a user with superuser privileges without spending several hours reading online to start using
thissystem? I just want to log in folks, and create some databases and tables...that should take like 2 minutes. Does
anyoneelse think this is ridiculous? Help please.  

Thanks.

Doug



new install, can't use - need password for postgres user

From
Douglas Hyde
Date:
I have just completed a first installation on Windows 2008 Server. I was very keen to work with PostGreSQL. I can't even do the basic things in pgAdmin III that I installed with the database, as I don't have a password and the documentation doesn't provide one. All that is mentioned in my digging is changing the pg_hba.conf file, but no details on how  - the manual says:

"19.1. The pg_hba.conf file
Client authentication is controlled by a configuration file, which traditionally is named pg_hba.conf and is stored in the database cluster's data directory. (HBA stands for host-based authentication.) A default pg_hba.conf file is installed when the data directory is initialized by initdb. It is possible to place the authentication configuration file elsewhere, however; see the hba_file configuration parameter...Each record specifies a connection type, a client IP address range (if relevant for the connection type), a database name, a user name, and the authentication method to be used for connections matching these parameters. The first record with a matching connection type, client address, requested database, and user name is used to perform authentication. There is no "fall-through" or "backup": if one record is chosen and the authentication fails, subsequent records are not considered. If no record matches, access is denied."

These instructions do not seem to be about the password for an individual users, but rather the instructions to allow clients and users who have passwords associated with those clients to be allowed access - pgAdmin is one of those?  Knowing it probably wouldn't work, I tried to edit that file, adding localhost and all users (followed guidance in the manual) and then PostGreSQL wouldn't restart. I reset the file and it restarted. When I run pgAdmin, it presents me a password challenge, so that client seems to be connected to the server. After further digging, there are several command line references to add new accounts, but they use unix commands (do those work in windows, and how do I get to command line in windows) and they also seem to require a user. So I have no password, don't know how to add one, or add a new user, and now have no documentation on what to do. Why wouldn't pgAdmin know the default password for the user "postgres" - I am not stupid, at least I don't think so, and would know to change that right away. I am now having my doubts about postgreSQL, as someone really should make this much simpler - starting off on the wrong foot. 

Bottom line, how do I add a user with superuser privileges without spending several hours reading online to start using this system? I just want to log in folks, and create some databases and tables...that should take like 2 minutes. I have been at it for more than 60 minutes. Does anyone else think this is ridiculous? Help please. 

Thanks. 

Doug

Re: new install, can't use - need password for postgres user

From
Jayadevan M
Date:
Hello,

>
> These instructions do not seem to be about the password for an
> individual users, but rather the instructions to allow clients and
> users associated with clients to be allowed access - pgAdmin is one
> of those?  


Yes


> file, adding localhost and all users (followed guidance in the
> manual) and then PostGreSQL wouldn't restart. When I run pgAdmin, it
> presents me a password challenge, so that client seems to be
> connected to the server. There are several command line references
> to add new accounts, but they use unix commands (do those work in
> windows, and how do I get to command line in windows)


Try psql. It should be there in bin directory under postgresql installation. For example -
D:\Applns\PostgreSQL\8.4\bin

H:\>psql -U postgres
Password for user postgres:
psql (8.4.3)

> one, or add a new user, and now have no documentation on what to do.
> Why wouldn't pgAdmin know the default password for the user
> "postgres" - I am not stupid, at least I don't think so, and would
> know to change that right away. I am now having my doubts about
> postgreSQL, as someone really should make this much simpler -
> starting off on the wrong foot.
>
> Bottom line, how do I add a user with superuser privileges without
> spending several hours reading online to start using this system? I
> just want to log in folks, and create some databases and
> tables...that should take like 2 minutes. Does anyone else think
> this is ridiculous? Help please.
You could try having just one line in the hba file?

local   all         all                                     trust


Then you could add users with passwords.... and have an entry similar to
host    all         all         192.168.0.0/16          md5

Read a bit more and change the
local   all         all                                     trust
to something more restrictive?
http://www.postgresql.org/docs/8.2/static/auth-pg-hba-conf.html

Regards,
Jayadevan





DISCLAIMER:


"The information in this e-mail and any attachment is intended only for the person to whom it is addressed and may contain confidential and/or privileged material. If you have received this e-mail in error, kindly contact the sender and destroy all copies of the original communication. IBS makes no warranty, express or implied, nor guarantees the accuracy, adequacy or completeness of the information contained in this email or any attachment and is not liable for any errors, defects, omissions, viruses or for resultant loss or damage, if any, direct or indirect."





Re: new install, can't use - need password for postgres user

From
Douglas Hyde
Date:
Thanks very much for getting back to me. 

OK, so I first change the pg_hba.conf file to add local hosts, restart the service, and that is good - postgresql restarted fine. 

I then run psql.exe from command line, as you suggested and I get the following:

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

So, I need a password. I tried several passwords, and none worked...did I set this password on install? If yes, then my bad and I will have to resintall, because I just don't remember what it was. Then I guess I am kind of dumb, though in my defence, I first installed this a month ago and I am just getting back to it now. 

Cheers,

Doug


Try psql. It should be there in bin directory under postgresql installation. For example -
D:\Applns\PostgreSQL\8.4\bin

H:\>psql -U postgres
Password for user postgres:
psql (8.4.3)


> tables...that should take like 2 minutes. Does anyone else think
> this is ridiculous? Help please.
You could try having just one line in the hba file?

local   all         all                                     trust


Then you could add users with passwords.... and have an entry similar to
host    all         all         192.168.0.0/16          md5

Read a bit more and change the
local   all         all                                     trust
to something more restrictive?
http://www.postgresql.org/docs/8.2/static/auth-pg-hba-conf.html

Regards,
Jayadevan





DISCLAIMER:


"The information in this e-mail and any attachment is intended only for the person to whom it is addressed and may contain confidential and/or privileged material. If you have received this e-mail in error, kindly contact the sender and destroy all copies of the original communication. IBS makes no warranty, express or implied, nor guarantees the accuracy, adequacy or completeness of the information contained in this email or any attachment and is not liable for any errors, defects, omissions, viruses or for resultant loss or damage, if any, direct or indirect."






Re: new install, can't use - need password for postgres user

From
Jayadevan M
Date:
> So, I need a password. I tried several passwords, and none
> worked...did I set this password on install? If yes, then my bad and
> I will have to resintall, because I just don't remember what it was.
> Then I guess I am kind of dumb, though in my defence, I first
> installed this a month ago and I am just getting back to it now.


You don't have to reinstall. I have a password for my postgresql. I tried a few combination of entries and this one seems to work and lets me through without a password from localhost.
Can you try this?
host   all    postgres                 127.0.0.1/32            trust

And you don't have to restart the server.

Regards,
Jayadevan






DISCLAIMER:


"The information in this e-mail and any attachment is intended only for the person to whom it is addressed and may contain confidential and/or privileged material. If you have received this e-mail in error, kindly contact the sender and destroy all copies of the original communication. IBS makes no warranty, express or implied, nor guarantees the accuracy, adequacy or completeness of the information contained in this email or any attachment and is not liable for any errors, defects, omissions, viruses or for resultant loss or damage, if any, direct or indirect."





Re: new install, can't use - need password for postgres user

From
Douglas Hyde
Date:
Thanks though it appears it is all my fault. I did indeed set up a password at install, and it was windows security policy that forced me to use something I normally wouldn't, hence the reason I forgot it. I can see how your solution below would work, but I suspect at some point, it will be better to know what that password is.

So, after a reinstall, I am up and running. Thanks for everything.

Cheers,

Doug 

> So, I need a password. I tried several passwords, and none
> worked...did I set this password on install? If yes, then my bad and
> I will have to resintall, because I just don't remember what it was.
> Then I guess I am kind of dumb, though in my defence, I first
> installed this a month ago and I am just getting back to it now.


You don't have to reinstall. I have a password for my postgresql. I tried a few combination of entries and this one seems to work and lets me through without a password from localhost.
Can you try this?
host   all    postgres                 127.0.0.1/32            trust

And you don't have to restart the server.

Regards,
Jayadevan






DISCLAIMER:


"The information in this e-mail and any attachment is intended only for the person to whom it is addressed and may contain confidential and/or privileged material. If you have received this e-mail in error, kindly contact the sender and destroy all copies of the original communication. IBS makes no warranty, express or implied, nor guarantees the accuracy, adequacy or completeness of the information contained in this email or any attachment and is not liable for any errors, defects, omissions, viruses or for resultant loss or damage, if any, direct or indirect."