Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Login to PostgreSQL - Login failed

Tags:

I installed psql and phpPgAdmin to my Ubuntu11.10 and don't know how to run it. What is the default username and password?

like image 644
Ivan Z. Horvat Avatar asked Mar 02 '12 19:03

Ivan Z. Horvat


People also ask

What is default password for postgres?

For most systems, the default Postgres user is postgres and a password is not required for authentication. Thus, to add a password, we must first login and connect as the postgres user.


2 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 
like image 58
Joachim Isaksson Avatar answered Sep 24 '22 00:09

Joachim Isaksson


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/

like image 40
Timur Sadykov Avatar answered Sep 24 '22 00:09

Timur Sadykov