簡體   English   中英

是否可以在 Azure Postgres DB 上執行 dblink_connect('dbname=db_name user=postgres')

[英]is it possible to execute dblink_connect('dbname=db_name user=postgres') on Azure Postgres DB

我在虛擬機上有一個 Postgresql DB,我在下面的代碼行中使用了幾個函數。

PERFORM dblink_connect('dbname=db_name user=postgres')

現在我正在遷移到 Azure Postgresql,經過幾天的處理,我已將整個應用程序設置遷移到 Azure。 但是我注意到上面代碼行的所有函數都失敗了,下面有錯誤。

SQL Error [2F003]: ERROR: password is required
Detail: Non-superusers must provide a password in the connection string.
Where: SQL statement "SELECT public.dblink_connect(l_current_connection,'dbname=' || CURRENT_DATABASE() || ' port=5432  user=postgres')"

我已經更改了代碼並嘗試了以下選項,但沒有成功。

選項1

在代碼中添加密碼

PERFORM dblink_connect('dbname=db_name user=postgres password=*****')

錯誤 1

SQL Error [2F003]: ERROR: password is required
Detail: Non-superuser cannot connect if the server does not request a password.
Hint: Target server's authentication method must be changed.
Where: SQL statement "SELECT public.dblink_connect(l_current_connection,'dbname=' || CURRENT_DATABASE() || ' port=5432  user=postgres password=*****')"

選項 2

請注意,我在函數 dblink_connect 中添加了_u (這是根據一些在線文章)

PERFORM dblink_connect_u('dbname=db_name user=postgres password=*****')

錯誤 2

SQL Error [2F003]: ERROR: password is required
Detail: Non-superuser cannot connect if the server does not request a password.
Hint: Target server's authentication method must be changed.
Where: SQL statement "SELECT public.dblink_connect_u(l_current_connection,'dbname=' || CURRENT_DATABASE() || ' port=5432  user=postgres password=*****')"

根據錯誤,用戶( postgres )需要是超級用戶才能使代碼正常工作,但是我在 Azure 文檔中讀到的是無法在 Azure postgresql 上創建超級用戶。

真的不可能在 Azure Postgres DB 上創建超級用戶嗎?

如果沒有,那么我怎樣才能使下面的代碼工作,任何選項都會非常有幫助。

如果對此沒有解決方案,那么不幸的是我需要再次將 PostgresDB 回滾到 VM。

看着那(這

Hint: Target server's authentication method must be changed.

您必須配置要連接的數據庫服務器,以便連接需要密碼。 dblink 將拒絕連接而不被要求提供憑據。

我們遇到了同樣的問題。 我們解決這個問題的方法只是將參數 hostaddr=127.0.0.1 添加到連接字符串中。

即dblink('hostaddr=127.0.0.1 dbname=db_name user=postgres password=***** port=5432')

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM