I created a user/role in postgres db and set default search_path to a specific schema. Now what I am trying to achieve is connect to the database using the new user/role and be able to work on that schema for all queries to database.
我在postgres db中创建了一个用户/角色,并将默认的search_path设置为特定的模式。现在我想要实现的是使用新用户/角色连接到数据库,并能够对该模式处理所有对数据库的查询。
CREATE ROLE ltv_dev WITH PASSWORD '<some password>';
So I was hoping if I can connect to the database using a connection string that is for the user/role from a .net core web client using Npgsql.
所以我希望我能使用Npgsql从.net核心Web客户端使用连接字符串连接到数据库。
My previous connection string was.
我之前的连接字符串是。
"NpgsqlConnectionStringOptions": {
"Server": "server_location",
"Port": 5432,
"Database": "db_name",
"UserId": "original_user_id",
"Password": "pwd"
}
I tried changing the UserId from the previous connection string to the new user/role and the password as well.
我尝试将UserId从之前的连接字符串更改为新用户/角色和密码。
My new connection string
我的新连接字符串
"NpgsqlConnectionStringOptions": {
"Server": "server_location",
"Port": 5432,
"Database": "db_name",
"UserId": "ltv_dev",
"Password": "password_for_the_role"
}
But it did not work.
但它没有用。
Is there any way I can connect to the database using a custom user/role from a .net client using Npgsql or is there another approach to solving this issue? Thanks
有没有办法可以使用Npgsql从.net客户端使用自定义用户/角色连接到数据库,还是有另一种方法可以解决这个问题?谢谢
1 个解决方案
#1
2
You have created a role without LOGIN privilige, the NOLOGIN option is by default in CREATE ROLE, or you can use CREATE USER:
您创建了一个没有LOGIN特权的角色,默认情况下NOLOGIN选项在CREATE ROLE中,或者您可以使用CREATE USER:
CREATE USER ltv_dev PASSWORD '<some password>';
you can see it in the documentation
你可以在文档中看到它
#1
2
You have created a role without LOGIN privilige, the NOLOGIN option is by default in CREATE ROLE, or you can use CREATE USER:
您创建了一个没有LOGIN特权的角色,默认情况下NOLOGIN选项在CREATE ROLE中,或者您可以使用CREATE USER:
CREATE USER ltv_dev PASSWORD '<some password>';
you can see it in the documentation
你可以在文档中看到它