How connect Postgres to localhost server using pgAdmin on Ubuntu?

前端 未结 6 720
日久生厌
日久生厌 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 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)

提交回复
热议问题