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脚