PostgreSQL中如何创建只读用户? - How do you create a read-only user in PostgreSQL?

问题:

I'd like to create a user in PostgreSQL that can only do SELECTs from a particular database.我想在 PostgreSQL 中创建一个只能从特定数据库执行 SELECT 的用户。 In MySQL the command would be:在 MySQL 中,命令将是:

GRANT SELECT ON mydb.* TO 'xxx'@'%' IDENTIFIED BY 'yyy';

What is the equivalent command or series of commands in PostgreSQL? PostgreSQL 中的等效命令或一系列命令是什么?

I tried...我试过了...

postgres=# CREATE ROLE xxx LOGIN PASSWORD 'yyy';
postgres=# GRANT SELECT ON DATABASE mydb TO xxx;

But it appears that the only things you can grant on a database are CREATE, CONNECT, TEMPORARY, and TEMP.但似乎您可以对数据库授予的唯一权限是 CREATE、CONNECT、TEMPORARY 和 TEMP。


解决方案:

参考一: https://stackoom.com/question/3BlS
参考二: How do you create a read-only user in PostgreSQL?
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章