{"id":3703,"date":"2016-01-12T13:52:39","date_gmt":"2016-01-12T13:52:39","guid":{"rendered":"https:\/\/blog.ed.gs\/2016\/01\/12\/add-read-only-mysql-user-2\/"},"modified":"2018-08-10T15:31:59","modified_gmt":"2018-08-10T14:31:59","slug":"add-read-only-postgres-user","status":"publish","type":"post","link":"https:\/\/ed.gs\/2016\/01\/12\/add-read-only-postgres-user\/","title":{"rendered":"Add Read-Only Postgres User"},"content":{"rendered":"
After the MySQL read only user created the other day, I now needed one for Postgres, so here’s how.<\/p>\n
psql databasehere\r\nCREATE USER moodle_readonly WITH ENCRYPTED PASSWORD 'blablablapasswordhere';\r\nGRANT CONNECT ON DATABASE moodle TO moodle_readonly;\r\nGRANT USAGE ON SCHEMA public TO moodle_readonly;\r\nGRANT SELECT ON ALL SEQUENCES IN SCHEMA public TO moodle_readonly;\r\nGRANT SELECT ON ALL TABLES IN SCHEMA public to moodle_readonly;\r\nALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO moodle_readonly;<\/pre>\nThis will give read access to the database moodle, but unlike most read only how-to’s on the internet, this will also give read-only access to new any tables created in that database.<\/p>\n","protected":false},"excerpt":{"rendered":"
After the MySQL read only user created the other day, I now needed one for Postgres, so here’s how. psql databasehere CREATE USER moodle_readonly WITH ENCRYPTED PASSWORD 'blablablapasswordhere'; GRANT CONNECT ON DATABASE moodle TO moodle_readonly; GRANT USAGE ON SCHEMA public TO moodle_readonly; GRANT SELECT ON ALL SEQUENCES IN SCHEMA public TO moodle_readonly; GRANT SELECT ON […]<\/p>\n","protected":false},"author":2,"featured_media":3846,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ep_exclude_from_search":false},"categories":[54],"tags":[],"yoast_head":"\n
Add Read-Only Postgres User - E<\/title>\n\n\n\n\n\n\n\n\n\n\n\n\t\n\t\n\t\n\n\n\t\n\t\n\t\n