views:

347

answers:

3

i have just installed postgresql and i specified password x during installation. when i try to do createdb and specify any password i get the message

createdb: could not connect to database postgres: FATAL: password authentication failed for user

same for createuser. how should i start?

Can i add myself as a user to the database?

A: 

The initdb command would help, I guess. It sets up the directory structure and whatnot to contain data and users and all.

try

initdb --help

for starters.

skrebbel
A: 

You probably need to update your pg_hba.conf file. This file controls what users can log in from what IP addresses. I think that the postgres user is pretty locked-down by default.

Neall
+1  A: 

Under Linux PostgresQL is usually configured to allow the root user to login as the postgres superuser "postgres" from the shell (console or ssh).

psql -U postgres

Then you would just create a new database as usual:

CREATE ROLE myuser LOGIN password 'secret';

CREATE DATABASE mydatabase ENCODING 'UTF8' OWNER myuser;

This should work without touching pg_hba.conf. If you want to be able to do this using some GUI tool over the network - then you would need to mess with pg_hba.conf.

Oliver Weichhold
i am working on windowsi ran initdb for my directory and have the configuration files present.now createdb worksbut when i do psql testi get the messageWARNING: Console code page (437) differs from Windows code page (1252) 8-bit characters might not work correctly. See psql reference page "Notes for Windows users" for details.and none of the commands work.
iamrohitbanga