Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PostgreSQL error Fatal: role “username” does not exist

Tags:

I'm setting up my PostgreSQL 9.1 in windows.

I can't do anything with PostgreSQL: can't createdb, can't createuser; all operations return the error message

Fatal: role root does not exist
root is my account name, which I created while installing Postgresql

But I am able to connect using:

 username : postgres   

How can I connect to postgres using role root?
There is a solution mentioned for linux platforms using su command here but not able to figure out solution for windows7

Thanks in Advance

like image 397
Abhishek Avatar asked Feb 02 '15 11:02

Abhishek


1 Answers

If you want to login to Postgres using the username root you need to first create such a user.

You first need to login as the Postgres super user. This is typically postgres (and is specified during installation):

psql -U postgres .... 

then you can create roles and databases:

psql (9.4.0) Type "help" for help.  postgres=# create user root with password 'verysecret'; CREATE ROLE postgres=# \q  c:\ c:\>psql -U root postgres psql (9.4.0) Type "help" for help.  postgres=> 

Logged in as the superuser you can also grant the root user the necessary privileges.

All parameters for psql are documented in the manual.

Creating users and databases is also documented in the manual:

  • connecting to the database
  • create user
  • create database
like image 159
a_horse_with_no_name Avatar answered Oct 12 '22 16:10

a_horse_with_no_name