英文:
Create user mapping without password how to configure authentication
问题
我正在尝试在PostgreSQL中创建一个不需要密码的用户映射,但我遇到了一个错误,提示如下:
local_db=> select * from employee;
ERROR: could not connect to server "testmachine02"
DETAIL: connection to server at "192.168.56.10", port 5432 failed: fe_sendauth: no password supplied
以下是我用来创建用户映射的命令:
CREATE USER MAPPING for app_user SERVER testmachine02 OPTIONS (password_required 'false');
我还创建了一个pgpass文件,其中包含以下条目:
localhost:5432:local_db:app_user:app_user123
192.168.56.10:5432:admin:admin:admin123
192.168.56.10:5432:remote_db:test:test123
尽管完成了这些步骤,但我仍然无法在没有密码的情况下访问表格。如何创建一个不需要密码的用户映射并访问表格?
在/pgsql目录下创建了一个.pgpass文件后,我得到了以下结果:图片链接。
英文:
I am trying to create a user mapping in PostgreSQL without a password, but I am encountering an error that says.
local_db=> select * from employee;
ERROR: could not connect to server "testmachine02"
DETAIL: connection to server at "192.168.56.10", port 5432 failed: fe_sendauth: no password supplied
Here is the command that I used to create the user mapping:
CREATE USER MAPPING for app_user SERVER testmachine02 OPTIONS (password_required 'false');
I also created a pgpass file with the following entries:
localhost:5432:local_db:app_user:app_user123
192.168.56.10:5432:admin:admin:admin123
192.168.56.10:5432:remote_db:test:test123
Despite these steps, I am still unable to access the table without a password. How can I create a user mapping without a password and access the table?
here is what I am getting after creating a .pgpass file under /pgsql:
答案1
得分: 1
密码文件不会通过您的客户端代理,以供服务器使用。 您需要密码的“.pgpass”文件是用于运行数据库服务器的操作系统用户的文件。 因此,通常情况下会是类似于“/var/lib/postgresql/.pgpass”的文件,而不是“/home/arahal/.pgpass”之类的文件。 如果您这样做并设置(password_required 'false'
),它将起作用。
但为什么不直接将密码放在用户映射中并完成呢? password_required 的目的是为您提供使用非基于密码的身份验证方法的选项。
英文:
The password file does not get proxied through your client to be used by server. The .pgpass file you need the password in is the one which would be used for the OS user who runs the database server. So often that would be something like "/var/lib/postgresql/.pgpass", not something like "/home/arahal/.pgpass". If you do this and set (password_required 'false')
, it will work.
But why not just stick the password in the user mapping and be done with it? The purpose of password_required is to give you the option of using non-password-based authentication methods.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论