我是postgres的新手,在启动postgresql-11服务之后,我输入'su postgres',并尝试创建我的db,但是显示如下消息:
[root@127 nemo]# systemctl enable postgresql-11.service
[root@127 nemo]# systemctl start postgresql-11.service
[root@127 nemo]# su postgres
bash-4.4$ createdb mydb
could not change directory to "/home/nemo": Permission denied
createdb: could not connect to database template1: FATAL: no pg_hba.conf entry for host "[local]", user "postgres", database "template1", SSL off"有谁可以帮我?
发布于 2019-02-06 15:47:29
createdb需要连接到数据库以发出CREATE DATABASE SQL语句,默认情况下它将使用:
postgres )template1作为数据库当它这样做时,在您的例子中,您会得到以下错误消息:
创建b:无法连接到数据库template1:致命:主机"本地“没有pg_hba.conf条目,用户"postgres",数据库"template1",SSL off
它表示postgres作为数据库用户没有通过Unix域套接字进行连接的权限(这就是[local]的意思)。
这是不寻常的,因为通常情况下,Unix上的postgres安装程序倾向于从以下规则开始安装pg_hba.conf:
local all postgres peer这意味着postgres Unix用户有权作为postgres数据库用户在本地连接到任何数据库,这符合管理数据库的需要,包括创建新的数据库。
实际上,您的pg_hba.conf看起来并不像默认的。立即着手解决数据库创建问题的最简单方法是编辑它,添加上面的行作为第一条规则,然后重新加载postgres服务。
发布于 2019-02-06 15:44:27
su postgres使您处于一种奇怪的状态,您当前处于无法访问的目录中。
您可能想要执行su - postgres,这将把您留在postgres的主目录中。
https://dba.stackexchange.com/questions/229029
复制相似问题