Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PostgreSQL on Mac OSX - cannot log in as postgres user

I installed postgresql and geodjango on Mac OSX following this tutorial word for word. For some reason

sudo su - postgres 

does not work. I put in my sudo password, but when I type "whoami" it's still my normal user login.

I know there is postgres user after I saw the list from

dscl . -list /Users UniqueID

Any idea why this is happening? I installed PSQL 9.1.1 server version.

Thank you.

like image 762
DavidL Avatar asked Dec 06 '11 06:12

DavidL


People also ask

How do I log into PostgreSQL on Mac?

This can be done by typing the following command into a terminal: This will start up a postgres server hosted locally on port 5432. The server will be run out of the directory /usr/local/var/postgres . This will connect to the server and access the postgres database.

How do I login as another user in PostgreSQL?

CREATE ROLE sa WITH LOGIN PASSWORD 'some-password. '; CREATE DATABASE master WITH OWNER sa; \c master; Now you are running this script using "psql" command line interface (CLI), so you get the message as below... CREATE ROLE CREATE DATABASE You are now connected to database "master" as user "postgres".

Why my PostgreSQL is not working?

To be sure that PostgreSQL is running, you can also restart it with systemctl restart postgresql. If this does not fix the problem, the most likely cause of this error is that PostgreSQL is not configured to allow TCP/IP connections. To correct this, edit your posgresql. conf file.


1 Answers

The postgres account probably has disabled login rights and/or /bin/false as the login shell.

In this case you had best invoke postgresql commands directly, eg: sudo -u postgres psql

That should work even with a disabled login shell.

like image 121
Craig Ringer Avatar answered Sep 19 '22 22:09

Craig Ringer