linux postgres用户,关于linux:在启动时创建postgres用户
我在启动时从monit运行bash文件,bash文件启动我的postgres服务器。
如果我的数据库目录不存在,我会:
1- initdb(postgresql / data /)
su - edge -c'/ usr / bin / initdb -D $ {DBDIR}'
2-复制修改后的pg_hba.conf和postgresql.conf文件到(postgresql / data /)
3-启动我的服务器
su - edge -c"/ usr / bin / pg_ctl -w -D $ {DBDIR} -l logfile start"
4- postgres createuser
- su - $ User -c'$ {DBDIR} -e -s postgres'
执行bash文件后
postgresql / data /已创建
文件被复制
服务器启动,
但是没有创建用户,因此无法访问我的数据库
错误:/ usr / bin / psql -U postgres
psql:致命:角色"postgres"不存在
我无法破译您的步骤#4,但postgres角色不存在的原因是因为步骤#1由用户edge运行并且它不要求创建postgres 角色通过-U,因此它会以超级用户身份创建egde角色。
每initdb文档:
-U username
--username=username
Selects the user name of the database superuser. This defaults to the name of the effective user running initdb. It is really not
important what the superuser's name is, but one might choose to keep
the customary name postgres, even if the operating system user's name
is different.
要么initdb -U postgres,要么您更喜欢名为edge的超级用户,请保持这样,但要使用psql -U edge启动psql,或将PGUSER环境变量设置为edge以避免每次都输入。
谢谢,我已经阅读了部分文档,但无论出于何种原因,我读到-U用于给出创建的超级用户的名称,而不是创建它。 应该只是因为在initdb之前无法创建超级用户这一事实。
总结
以上是生活随笔为你收集整理的linux postgres用户,关于linux:在启动时创建postgres用户的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: linux内核路由反向检查,反向路径过滤
- 下一篇: linux互信封装脚本,使用shell脚