在mint ubuntu上安裝了新的postgres 8.4。如何爲postgres創建用戶並使用psql登錄?如何在全新安裝後登錄並驗證Postgresql?
當我鍵入psql裏,它只是告訴我
psql: FATAL: Ident authentication failed for user "my-ubuntu-username"
在mint ubuntu上安裝了新的postgres 8.4。如何爲postgres創建用戶並使用psql登錄?如何在全新安裝後登錄並驗證Postgresql?
當我鍵入psql裏,它只是告訴我
psql: FATAL: Ident authentication failed for user "my-ubuntu-username"
有可以使用兩種方法。兩者都需要創建一個數據庫用戶和。
使用CREATEUSER和CREATEDB,
$ sudo -u postgres createuser -s $USER
$ createdb mydatabase
$ psql -d mydatabase
使用SQL管理命令,並使用密碼通過TCP
$ sudo -u postgres psql postgres
連接和,然後在PSQL外殼
CREATE ROLE myuser LOGIN PASSWORD 'mypass';
CREATE DATABASE mydatabase WITH OWNER = myuser;
然後你就可以登錄,
$ psql -h localhost -d mydatabase -U myuser -p <port>
如果您不知道端口,你可以隨時通過運行下面的得到它,爲postgres
用戶,
SHOW port;
或者,
$ grep "port =" /etc/postgresql/*/main/postgresql.conf
postgres
用戶我建議不是修改postgres
用戶。
postgres
「登錄」到操作系統。你應該有root權限才能認證爲postgres
。postgres
的身份登錄,這是SQL Server的SA
的PostgreSQL等效項,您必須具有對基礎數據文件的寫入訪問權限。而且,這意味着無論如何你都可以正常破壞。我知道如果使用數據庫超級用戶(-s)而不是非超級用戶,則不會出現問題。對我來說,下一個問題是,即使DB用戶不是超級用戶,也可以做到這一點。 – Hartmut 2013-03-16 16:09:24
你所得到的錯誤是因爲你,Ubuntu的用戶名不是有效的Postgres用戶。
你需要告訴psql裏使用什麼數據庫用戶名
psql -U postgres
您可能還需要指定數據庫連接到
psql -U postgres -d <dbname>
如果您的數據庫客戶端使用TCP/IP和你連接在您的pg_hba.conf中配置ident auth,檢查是否已安裝並運行identd。即使您只有本地客戶端連接到「本地主機」,這也是強制性的。
而且提防時下的identd可能要IPv6 enabled PostgreSQL的歡迎,其連接到本地主機的客戶端。
還可以連接到數據庫的 「普通」 用戶(不是Postgres的):
postgres=# \connect opensim Opensim_Tester localhost;
Password for user Opensim_Tester:
You are now connected to database "opensim" as user "Opensim_Tester" on host "localhost" at port "5432"
選中此[博客文章(http://www.depesz.com/index.php/2007/10/04/IDENT /)。 – 2010-01-31 18:41:18