Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sudo: unknown user: postgres

Tags:

I'm currently trying to run postgresql (9.3) on my iMac but I have some issues with user postgres and psql connection.

I bought an iMac old generation (with snow Leopard) that was migrated to Lion. As followed on other StackOverflow topics I added this line on my .bash_profile :

export PATH=/Library/PostgreSQL/9.3/bin:/usr/bin:$PATH

When launching pg :

sudo su postgres -c '/Library/PostgreSQL/9.3/bin/pg_ctl -D /Library/PostgreSQL/9.3/data/ -m fast start'

it returns :

su: unknown login: postgres

What should I do ?

like image 405
user1713964 Avatar asked May 22 '13 10:05

user1713964


People also ask

What is sudo password for postgres?

By all means read the linked answer, sudo passwd postgres should not be used, instead run sudo -u postgres psql postgres and enter \password postgres .

What is sudo su postgres?

sudo - su postgres psql. The psql command gives us access to the Postgres interactive terminal. Create a username by running the command below CREATE USER ubuntu_user SUPERUSER; We have to create a password for the user with the command below ALTER USER power_user WITH PASSWORD 'password';

What is Initdb in PostgreSQL?

initdb initializes the database cluster's default locale and character set encoding. The character set encoding, collation order ( LC_COLLATE ) and character set classes ( LC_CTYPE , e.g., upper, lower, digit) can be set separately for a database when it is created.

What is running on port 5432?

Port 5432 is already in use Usually this means that there is already a PostgreSQL server running on your Mac. If you want to run multiple servers simultaneously, use different ports.


2 Answers

The default postgres user in OSX 10.8 & 10.9 should be _postgres, you can use sudo -u _postgres to run the command

like image 190
chancyWu Avatar answered Oct 01 '22 10:10

chancyWu


I got this same error (su: unknown login: postgres) when trying sudo su - postgres. I then managed to log in using sudo psql -U my.username postgres.

I could then create the appropriate users, etc.

Hope that helps.

like image 37
avjaarsveld Avatar answered Oct 01 '22 10:10

avjaarsveld