linux postgres用户,关于linux:在启动时创建postgres用户
我在啟動(dòng)時(shí)從monit運(yùn)行bash文件,bash文件啟動(dòng)我的postgres服務(wù)器。
如果我的數(shù)據(jù)庫(kù)目錄不存在,我會(huì):
1- initdb(postgresql / data /)
su - edge -c'/ usr / bin / initdb -D $ {DBDIR}'
2-復(fù)制修改后的pg_hba.conf和postgresql.conf文件到(postgresql / data /)
3-啟動(dòng)我的服務(wù)器
su - edge -c"/ usr / bin / pg_ctl -w -D $ {DBDIR} -l logfile start"
4- postgres createuser
- su - $ User -c'$ {DBDIR} -e -s postgres'
執(zhí)行bash文件后
postgresql / data /已創(chuàng)建
文件被復(fù)制
服務(wù)器啟動(dòng),
但是沒有創(chuàng)建用戶,因此無法訪問我的數(shù)據(jù)庫(kù)
錯(cuò)誤:/ usr / bin / psql -U postgres
psql:致命:角色"postgres"不存在
我無法破譯您的步驟#4,但postgres角色不存在的原因是因?yàn)椴襟E#1由用戶edge運(yùn)行并且它不要求創(chuàng)建postgres 角色通過-U,因此它會(huì)以超級(jí)用戶身份創(chuàng)建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的超級(jí)用戶,請(qǐng)保持這樣,但要使用psql -U edge啟動(dòng)psql,或?qū)GUSER環(huán)境變量設(shè)置為edge以避免每次都輸入。
謝謝,我已經(jīng)閱讀了部分文檔,但無論出于何種原因,我讀到-U用于給出創(chuàng)建的超級(jí)用戶的名稱,而不是創(chuàng)建它。 應(yīng)該只是因?yàn)樵趇nitdb之前無法創(chuàng)建超級(jí)用戶這一事實(shí)。
總結(jié)
以上是生活随笔為你收集整理的linux postgres用户,关于linux:在启动时创建postgres用户的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: linux内核路由反向检查,反向路径过滤
- 下一篇: linux互信封装脚本,使用shell脚