psql: FATAL: Peer authentication failed for user “dev”

后端 未结 12 853
盖世英雄少女心
盖世英雄少女心 2020-12-12 09:40

when i create a new user, but it cannot login the database.
I do that like this:

postgres@Aspire:/home/XXX$ createuser dev
Shall the new role be a superu         


        
12条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-12 10:08

    Try:

    psql -U user_name  -h 127.0.0.1 -d db_name
    

    where

    • -U is the database user name
    • -h is the hostname/IP of the local server, thus avoiding Unix domain sockets
    • -d is the database name to connect to

    This is then evaluated as a "network" connection by Postgresql rather than a Unix domain socket connection, thus not evaluated as a "local" connect as you might see in pg_hba.conf:

    local   all             all                                     peer
    

提交回复
热议问题