PostgreSQL: Why psql can't connect to server?

前端 未结 22 2151
情书的邮戳
情书的邮戳 2020-12-07 10:40

I typed psql and I get this:

psql: could not connect to server: No such file or directory
    Is the server running locally and accepting
    con         


        
22条回答
  •  再見小時候
    2020-12-07 11:02

    quick howto on debian to remotely access postgres database on server from the psql client: (the changed config is doc'd in the files):

    1. edit /etc/postgresql/10/main/postgresql.conf with listen_address *
    2. edit /etc/postgresql/10/main/pg_hba.conf and add line in the end with host all all 0/0 md5
    3. create login role postgres=# CREATE ROLE remoteuser LOGIN WITH PASSWORD 'foo'
    4. sudo /etc/init.d/postgresql restart changes take effect

    5. login from clientside with psql --host=ipofserver --port=5432 --username=remoteuser --password --dbname=mydb

    6. the password is interactivly asked which in this case is foo

提交回复
热议问题