Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating DB with pass required, but pass not needed to connect

Status
Not open for further replies.

pgosse

Programmer
Sep 26, 2001
42
CA
Hi folks. I'm running to a problem which I can't figure out.

I'm creating a database using the following command:

createdb -U pablo -W pablotest1

I'm prompted to enter the password to create the DB, and after doing so the db is created successfully.

However, when I connect to this database via a php script, I can enter any valid database user, and I can enter anything for the password (or leave it blank), and I'm still able to connect.

So, each of these connection calls works:

$conn->Connect('localhost','pablo','realpass','pablotest1');
$conn->Connect('localhost','pablo','','pablotest1');
$conn->Connect('localhost','pablo','abc123','pablotest1');
$conn->Connect('localhost','bsc','notapass','pablotest1');
$conn->Connect('localhost','bsc','','pablotest1');

Obviously I'm doing something wrong here, since I don't want scripts to be able to connect without the proper credentials.

Can anyone give me an idea if I'm executing the createdb command incorrectly, or if something on the server level might be causing this?

Cheers and TIA,

Pablo
 
the problem is probably in the file pg_hba.conf (usually in your data directory)

you probably have a row something like

local all all trust

(the row may be different depending ot the version you use)

but if you put md5 instead of trust, you will require the password (see the comment in the file itself, they are quite descriptive)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top