This article is half-done without your Comment! *** Please share your thoughts via Comment ***
A PostgreSQL Fatal error like role or username does not exist. This is a very common error which is facing by PostgreSQL Users.
Actually, this is happening because of misconfiguration of System username and Database Username.
Most of the Linux users are trying to log in PostgreSQL using root user. But actually, this is wrong.
You will need to become the operating system user under which PostgreSQL was installed to create the first user account.
Generally, the default user name is Postgres and default database is also Postgres.
Once you install PostgreSQL on Linux, you should set the password for the Postgres user which is the default super user of PostgreSQL.
Please do not try to log in with any other default Linux or Unix system user name.
Set password for the default Postgres user:
Create another role using “postgres”:
Creating new role “dbrnd”. -p = set the password and -d = allow to create database.
Содержание
- Please visit other related articles.
- Leave a Reply Cancel reply
- 16 Answers 16
Please visit other related articles.
thank you for this very useful information
but I still face the same trouble everytime I followed the commands that you wrote but still getting the same fatal error
i am running the database through docker …
Leave a Reply Cancel reply
Anvesh Patel Email Subscription ! About Me!
I’m Anvesh Patel, a Database Engineer certified by Oracle and IBM. I’m working as a Database Architect, Database Optimizer, Database Administrator, Database Developer. Providing the best articles and solutions for different problems in the best manner through my blogs is my passion. I have more than six years of experience with various RDBMS products like MSSQL Server, PostgreSQL, MySQL, Greenplum and currently learning and doing research on BIGData and NoSQL technology. — Hyderabad, India.
About DBRND !
This is a personal blog (www.dbrnd.com).
Any views or opinions represented in this blog are personal and belong solely to the blog owner and do not represent those of people, institutions or organizations that the owner may or may not be associated with in professional or personal capacity, unless explicitly stated.
Feel free to challenge me, disagree with me, or tell me I’m completely nuts in the comments section of each blog entry, but I reserve the right to delete any comment for any reason whatsoever (abusive, profane, rude, or anonymous comments) — so keep it polite.
The content of this website is protected by copyright. No portion of this website may be copied or replicated in any form without the written consent of the website owner.
Running PostgreSQL server on Void Linux. After installing ran initdb as OS user ‘postgres’:
creating directory /var/lib/postgresql/data . ok creating subdirectories . ok selecting default max_connections . 100 selecting default shared_buffers . 128MB selecting dynamic shared memory implementation . posix creating configuration files . ok running bootstrap script . ok performing post-bootstrap initialization . locale: Cannot set LC_MESSAGES to default locale: No such file or directory ok syncing data to disk . ok
WARNING: enabling «trust» authentication for local connections You can change this by editing pg_hba.conf or using the option -A, or —auth-local and —auth-host, the next time you run initdb.
Success. You can now start the database server using: pg_ctl -D /var/lib/postgresql/data -l logfile start
I’ve then proceeded to create the service, grant the ownership to ‘postgres’ and start it:
will give me the following error:
I’ve tried granting ownership of /etc/sv/postgresql to ‘postgres’, but no luck.
These were my sources:
I do not know what to do next.
EDIT: Stumbled upon psql: FATAL: role “postgres” does not exist. Cannot run psql -l because I get the same error, no matter which user I run psql as.
I’m a postgres novice.
I installed the postgres.app for mac. I was playing around with the psql commands and I accidentally dropped the postgres database. I don’t know what was in it.
And I’m stuck at sudo -u postgres psql postgres
ERROR MESSAGE: psql: FATAL: role «postgres» does not exist
This is what prints out of psql -l
So what are the steps I should take? Delete an everything related to psql and reinstall everything?
Thanks for the help guys!
16 Answers 16
NOTE: If you installed postgres using homebrew, see the comment from @user3402754 below.
Note that the error message does NOT talk about a missing database, it talks about a missing role. Later in the login process it might also stumble over the missing database.
But the first step is to check the missing role: What is the output within psql of the command du ? On my Ubuntu system the relevant line looks like this:
If there is not at least one role with superuser , then you have a problem 🙂
If there is one, you can use that to login. And looking at the output of your l command: The permissions for user on the template0 and template1 databases are the same as on my Ubuntu system for the superuser postgres . So I think your setup simple uses user as the superuser. So you could try this command to login:
If user is really the DB superuser you can create another DB superuser and a private, empty database for him:
Источник: