日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

linux postgres用户,关于linux:在启动时创建postgres用户

發布時間:2025/6/15 45 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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用户的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。