我似乎无法从我的 Ubuntu 终端运行 PSQL 脚本文件。具体来说,当我运行时,./populate_ppima_db.sh melon melon
我得到以下输出:
Insert Basic Data
psql: FATAL: Peer authentication failed for user "melon"
psql: FATAL: Peer authentication failed for user "melon"
Insert PPIMA data
psql: FATAL: Peer authentication failed for user "melon"
我很困惑。我需要做什么才能PSQL
与我的用户一起从我的终端运行脚本?
这是我的pg_hba.conf
文件:
# Database administrative login by Unix domain socket
local all all md5
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all md5
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local replication postgres peer
#host replication postgres 127.0.0.1/32 md5
#host replication postgres ::1/128 md5
答案1
好吧,运行以下命令后:
sudo -u postgres psql -d postgres -c "alter user melon with password 'melon'"
并将我的pg_hba.conf
文件中的以下几行从
# "local" is for Unix domain socket connections only
local all all md5
到
# "local" is for Unix domain socket connections only
local all all password
脚本现在可以正确运行。
如果我要完全诚实,我无法解释原因,但这确实解决了我的问题。