I installed psql and phpPgAdmin to my Ubuntu11.10 and don't know how to run it. What is the default username and password?
3 Answers
There is no default username and password without you creating one. The simplest possible setup is to follow these steps to set up your own user as a superuser.
At a terminal prompt, create a postgres user with your own username
sudo -u postgres createuser --superuser $USER
Start the postgresql command prompt as your username but running as root since you didn't set a password yet;
sudo -u postgres psql
At the postgresql prompt, set your password;
\password $USER
After that, you should be able to log on just fine.
The setup is more thoroughly documented here.
EDIT:
If you get stuck not being able to authenticate automatically as the postgres user, you may want to compare your /etc/postgresql/9.1/main/pg_hba.conf (ie authentication config file) with the following lines from mine that works; you can get the uncommented ones using
grep -v ^# pg_hba.conf
The "local" lines should be the essential ones in this case since you can't authenticate even from the same machine;
local all postgres peer
local all all peer
host all all 127.0.0.1/32 md5
host all all ::1/128 md5
- 176,943
- 25
- 281
- 294
-
1$sudo -u postgres createuser --superuser $USER Password: createuser: could not connect to database postgres: FATAL: password authentication failed for user "postgres" – Ivan Z. Horvat Mar 05 '12 at 20:21
-
@IvanZ.Horvat Very odd, by default in Ubuntu, Postgresql is configured to use 'ident sameuser' authentication for any connections from the same machine, which means you should not have to use a password once you're logged in as that user in the OS. Just verified using my Ubuntu 11.10 that I can just log in like that on a fresh install. – Joachim Isaksson Mar 05 '12 at 20:30
-
@IvanZ.Horvat Added some info on hba.conf (the authentication configuration file) to my answer. – Joachim Isaksson Mar 07 '12 at 11:01
-
I'm getting: sudo: unknown user: postgres. I installed Postgres with Postgres.app for OS X. – Olivier Lalonde May 26 '13 at 07:50
There is a good article by digital ocean here.
Key point: Without creating another user,access postgres as the default account named 'postgres'
$ sudo -u postgres psql
One can always exit using \q
- 1,043
- 10
- 6
During the installation process you've probably missed steps:
Now we need to reset the password for the ‘postgres’ admin account for the server, so we can use this for all of the system administration tasks. Type the following at the command-line (substitute in the password you want to use for your administrator account):
sudo su postgres -c psql template1
template1=# ALTER USER postgres WITH PASSWORD 'password';
template1=# \q
That alters the password for within the database, now we need to do the same for the unix user ‘postgres’:
sudo passwd -d postgres
sudo su postgres -c passwd
Now enter the same password that you used previously.
http://hocuspokus.net/2008/05/install-postgresql-on-ubuntu-804/
- 10,859
- 7
- 32
- 45
-
ivan@ivan-Inspiron-N5110:~$ sudo su postgres -c psql template1 [sudo] password for ivan: Password: – Ivan Z. Horvat Mar 06 '12 at 11:09
-
psql: FATAL: password authentication failed for user "postgres" – Ivan Z. Horvat Mar 06 '12 at 11:12