0

After installing postgresql, I tried it out, typing createdb mydb, like it's written in the documentation. Then the following error occured:

createdb: could not connect to database postgres: FATAL:  role "xxx" does not exist

I studied the documentation, where is said:

You will need to become the operating system user under which PostgreSQL was installed (usually postgres) to create the first user account

I tried this by accessing psql (in my case with sudo -u postgres psql, using Ubuntu 12.10). But then what should I do?

2
  • have you created a user for your database ? (not pstgres which is the superuser) Commented Mar 26, 2013 at 15:53
  • What happens when you just "su - postgres" to become the postgres user, and then try "createdb"? Commented Mar 26, 2013 at 15:54

2 Answers 2

1

if the db is owned by user postgres you can do the following

createdb -U postgres dbname

since by default postgresql will trust connections from localhost.

Sign up to request clarification or add additional context in comments.

2 Comments

Not working.. Resolving to: createdb: could not connect to database postgres: FATAL: Peer authentication failed for user "postgres"
hmm I am guessing whatever you used to install the server modified the default config to not trust. try sudo su - postgres and then run the createdb. not sure
0
su - postgres

and after you have been logged in:

createdb mydb

3 Comments

su - postgresql gives me following output: Unknown id:postgresql
su - postgres is the user.
@SaschaMayr sorry, my typo, try su - postgres (without ql at the end), my answer edited

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.