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 ?
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 .
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';
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.
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.
The default postgres user in OSX 10.8 & 10.9 should be _postgres
, you can use sudo -u _postgres
to run the command
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With