Reputation: 3679
Totally new to postgresql; just had it installed (version 14.1) for the first time via brew on m1 Mac. Installation works fine, but I thought the installation process shall also create a superuser called 'postgres' but when trying to connect to PostgreSql as 'postgres' using
sudo -u postgres psql
It says unknown user: postgres
What am I missing here?
UPDATE: sorry but forgot to add that I am following a book which uses postgresql version 13; in the book it says after installing via brew it auto creates a superuser 'postgres' which can be used to log in the server in order to create database.
Upvotes: 1
Views: 2646
Reputation: 3679
Just in case this might help others using m1 macOS with version 14.1 postgresql. After installing with brew, simply run
brew services start postgresql
psql postgres
to connect to the server.
The book I am reading used version 13 and according to the book installing via brew will auto create a superuser postgres and connect using command sudo -u postgres psql
but on version 14.1 this doesn't seem to be the case anymore.
Upvotes: 5
Reputation: 44363
"unknown user: postgres" looks like a sudo error message (or a fragment of one), not a PostgreSQL error message. It is complaining about the OS user named postgres, not the database user with the same spelling. You don't know if the database user of that name exists or not, as you haven't gotten far enough to tell.
What the installation method does depends on what the installation method was, which you haven't told us.
Upvotes: 0
Reputation: 4707
Try to log in with your current user. Here my output
~ $ whoami
macbook
~ $ psql
psql (13.3)
Type "help" for help.
macbook=# select * from user;
user
---------
macbook
(1 row)
macbook=#
So postgresql create macbook
user, as my username in system.
I have MacOS Big Sur 11.6 and postgresql13.3.
Upvotes: 0