postgresqlHow do I grant access to a PostgreSQL database?
-
You can grant access to a PostgreSQL database by using the
GRANTcommand. -
For example, to grant read and write access to a user named
bobfor a database namedmydb, you would use the following command:
GRANT ALL PRIVILEGES ON DATABASE mydb TO bob;
-
This command grants
boball privileges on themydbdatabase, including the ability to create tables, insert data, and modify data. -
If you want to grant only read access to
bob, you can use the following command:
GRANT CONNECT ON DATABASE mydb TO bob;
-
This command grants
bobonly the ability to connect to themydbdatabase. -
You can also grant access to specific tables or columns within a database. For example, to grant
bobread access to a table namedmytablewithinmydb, you can use the following command:
GRANT SELECT ON mytable TO bob;
- For more information about granting access to PostgreSQL databases, see the PostgreSQL documentation.
More of Postgresql
- How can I troubleshoot zero damaged pages in PostgreSQL?
- How can I use PostgreSQL's "zero if null" feature?
- How can Zalando use PostgreSQL to improve its software development?
- How do I use PostgreSQL ZonedDateTime to store date and time information?
- How can I use PostgreSQL with YAML?
- How do I use PostgreSQL's XMLTABLE to parse XML data?
- How can I monitor PostgreSQL performance using Zabbix?
- How can I use PostgreSQL and ZFS snapshots together?
- How can I set a PostgreSQL interval to zero?
- How can I integrate PostgreSQL with Yii2?
See more codes...