How connect Postgres to localhost server using pgAdmin on Ubuntu?

前端 未结 6 716
日久生厌
日久生厌 2020-12-12 10:59

I installed Postgres with this command

sudo apt-get install postgresql postgresql-client postgresql-contrib libpq-dev

Using psql --ve

相关标签:
6条回答
  • 2020-12-12 11:35

    First you should change the password using terminal. (username is postgres)

    postgres=# \password postgres

    Then you will be prompted to enter the password and confirm it.

    Now you will be able to connect using pgadmin with the new password.

    0 讨论(0)
  • 2020-12-12 11:50

    You haven't created a user db. If its just a fresh install, the default user is postgres and the password should be blank. After you access it, you can create the users you need.

    0 讨论(0)
  • 2020-12-12 11:52

    Modify password for role postgres:

    sudo -u postgres psql postgres
    
    alter user postgres with password 'postgres';
    

    Now connect to pgadmin using username postgres and password postgres

    Now you can create roles & databases using pgAdmin

    How to change PostgreSQL user password?

    0 讨论(0)
  • 2020-12-12 11:56

    if you open the psql console in a terminal window, by typing

    $ psql

    you're super user username will be shown before the =#, for example:

    elisechant=#$

    That will be the user name you should use for localhost.

    0 讨论(0)
  • 2020-12-12 12:01

    It helps me:


    1. Open the file pg_hba.conf

    sudo nano /etc/postgresql/9.x/main/pg_hba.conf

    and change this line:

    Database administrative login by Unix domain socket
    local   all             postgres                                md5
    

    to

    Database administrative login by Unix domain socket
    local   all             postgres                                trust
    
    1. Restart the server

      sudo service postgresql restart

    2. Login into psql and set password

      psql -U postgres

    ALTER USER postgres with password 'new password';

    1. Again open the file pg_hba.conf and change this line:
    Database administrative login by Unix domain socket
        local   all             postgres                                trust

    to

        Database administrative login by Unix domain socket
        local   all             postgres                                md5
    1. Restart the server

      sudo service postgresql restart


    It works.


    Helpful links
    1: PostgreSQL (from ubuntu.com)

    0 讨论(0)
  • 2020-12-12 12:01

    Create a user first. You must do this as user postgres. Because the postgres system account has no password assigned, you can either set a password first, or you go like this:

    sudo /bin/bash
    # you should be root now  
    su postgres
    # you are postgres now
    createuser --interactive
    

    and the programm will prompt you.

    0 讨论(0)
提交回复
热议问题