I want to do some cross database references in my application. Briefly, i have two databases called meta and op. I want to do some select query from meta to a table in op database like below but getting the below error. I tried with password and without password. by the way caixa user is a non-super user and my target server (op db server is having MD5 authentication mode.)
meta=> select * from dblink('dbname=op password=caixa','SELECT op_col from op_table') AS t(op_col varchar);
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.
What the HINT in the above error message suggests? do i need to change the server’s auth mode? Without changing the server’s auth mode (MD5) can’t i run the above query?
From documentation:
and
That means your
dblinkcall is usingdblink_connectimplicitly. Usedblink_connect_uinstead or change your auth method to e.g. md5.Note that you also need grant execute privilege to
caixarole, for example by:Working example (after
GRANT):EDIT:
Sorry for slightly misleading answer. Of course you don’t need
dblink_connect_ufor md5 authenticatedconnection. There is one possibility I see. PostgreSQL has two different connection types: host and local.
Running:
psql -h localhost ..incorporates host connection, but
dblink_connect('mycon','dbname=vchitta_op user=caixa password=caixa');uses local type, so if you have non-password method for local connection (for example ident method or trust), then it returns
Check
dblink_connect('mycon','hostaddr=127.0.0.1 dbname=vchitta_op user=caixa password=caixa')for host connection. For clarity if possible please post your
pg_hba.conf.I also checked what about
CONNECTprivilege onvchitta_opDB, but error message is different: