1

Whenever I try to run 'psql' I receieve the following error message:

ahcarpenter@ubuntu:~$ psql
psql: FATAL:  role "ahcarpenter" does not exist

Any ideas on how to fix this?

Drew
  • 2,583
  • 5
  • 36
  • 54
  • See [PostgreSQL error: Fatal: role “username” does not exist](http://stackoverflow.com/questions/11919391/postgresql-error-fatal-role-username-does-not-exist) – Daniel Vérité Aug 29 '13 at 00:21

1 Answers1

1

That happens because

$ psql 

is equivalent to

$ psql ahcarpenter -U ahcarpenter

As that user does not exist enter as user postgres

$ psql -U postgres

Once inside create the user and the database "ahcarpenter".

create user ahcarpenter;
create database ahcarpenter with owner ahcarpenter;

exit

\q

Reenter

$ psql
Clodoaldo Neto
  • 118,695
  • 26
  • 233
  • 260
  • 1
    So after trying 'psql -U postgres' I get the following: 'psql: FATAL: Peer authentication failed for user "postgres"'. – Drew Aug 29 '13 at 00:23
  • @Drew - taking your other questions into account, you're going to have to sit down for an hour or so and at least skim the manuals and a tutorial. You're not going to get anywhere until you have at least a basic understanding of some of the terms used. – Richard Huxton Aug 29 '13 at 06:27
  • @RichardHuxton Do you by any chance know how to resolve the error of which I wrote above? – Drew Aug 29 '13 at 12:33
  • Yes - either run as the required user, or correct your pg_hba.conf to not require peer auth. Now you can either skim the manuals and read a tutorial to find out all the details, or I can tell you and you can come back in 5 minutes when you get stuck again. – Richard Huxton Aug 29 '13 at 13:11
  • So I edited my pg_hba.conf file to include the following line: local ahcarpenter ahcarpenter After trying to run 'psql' again, I received the following error: "psql: FATAL: no pg_hba.conf entry for host "[local]", user "ahcarpenter", database "ahcarpenter", SSL off" – Drew Aug 30 '13 at 17:12
  • @Drew Did you reload or restart the server? – Clodoaldo Neto Aug 30 '13 at 19:24
  • @ClodoaldoNeto I'm not sure. I exited out of the terminal window and then reopened it. Would that cause the server to be reloaded/restarted the next time I ran 'psql'? – Drew Aug 30 '13 at 19:27
  • @Drew No. What is the OS? – Clodoaldo Neto Aug 30 '13 at 20:49
  • @ClodoaldoNeto Ubuntu – Drew Aug 30 '13 at 20:52
  • 1
    @Drew If it were a Redhat derivated OS I would do `service postgresql reload` Try that. If it does not work ask an Ubuntu guru how to reload a service. – Clodoaldo Neto Aug 30 '13 at 20:55