How to set the password for PostgreSQL administration?

6

I installed PostgreSQL on my Ubuntu using "apt-get". I've been using "sudo" to perform operations (actually following a tutorial), but now I want to administer the DBMS with a client that asks me for the admin password "postgres".

How do I set this password?

    
asked by Nigini 14.12.2013 в 14:36

2 answers

7

To change the password for the postgres user, type the command:

$ sudo passwd postgres

After executing the command the following messages will appear:

Digite a nova senha UNIX: 
Redigite a nova senha UNIX: 

Enter your password and retype it later. After that, we will log in with the postgres user.

$ su postgres

The password that will be required is the same as the one we just changed.

Now let's change the password to connect to the bank.

This command is for version 7 or higher:

$ psql -c "ALTER USER postgres WITH PASSWORD 'nova_senha'" -d template1

Where nova_senha will be the password you want.

Source: vivaolinux .

    
14.12.2013 в 15:01
4

Access the Postgres administration database with this command:

sudo -u postgres psql postgres

Set the admin user password using:

\password postgres

After entering and confirming the password use the shortcut "Crtl + D" to end the bank administration.

    
14.12.2013 в 14:36