{"id":19074861,"url":"https://github.com/phuclam202/denied-schema-public","last_synced_at":"2025-07-02T11:41:44.393Z","repository":{"id":243602345,"uuid":"806040265","full_name":"PhucLam202/Denied-Schema-Public","owner":"PhucLam202","description":"Permission denied for schema public","archived":false,"fork":false,"pushed_at":"2024-06-11T15:07:58.000Z","size":7,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-02T17:49:41.873Z","etag":null,"topics":["error","postgres","postgresql","schema"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PhucLam202.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-26T07:48:26.000Z","updated_at":"2024-06-12T08:29:03.000Z","dependencies_parsed_at":"2024-06-10T05:28:58.936Z","dependency_job_id":"667816e1-34ba-47ac-8f9e-209d15926357","html_url":"https://github.com/PhucLam202/Denied-Schema-Public","commit_stats":null,"previous_names":["phuclam202/denied-schema-public"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PhucLam202%2FDenied-Schema-Public","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PhucLam202%2FDenied-Schema-Public/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PhucLam202%2FDenied-Schema-Public/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PhucLam202%2FDenied-Schema-Public/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PhucLam202","download_url":"https://codeload.github.com/PhucLam202/Denied-Schema-Public/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240127089,"owners_count":19751938,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["error","postgres","postgresql","schema"],"created_at":"2024-11-09T01:52:39.812Z","updated_at":"2025-02-22T04:41:48.943Z","avatar_url":"https://github.com/PhucLam202.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Denied-Schema-Public\n1. [overview](#overview)\n2. [troubleshooting](#causes)\n    1.  [causes](#causes)\n    2.  [solutions](#solutions)  \n3. [flowworking](#flowworking)\n\n## Overview\nThe error \"permission denied for schema public\" occurs when a user or role does not have the necessary permissions to perform an action on the \"public\" schema.\n\n## Causes\n* Normally, after allowing a user to CREATE tables within a database, you didn't have to specifically define that they had the permission to do that within a SCHEMA, since public would be the default one.\n* The user or role does not have the CONNECT privilege on the database. This means they cannot connect to the database at all.\n\n\n### Solutions\n* To resolve this error, you need to identify the specific cause and grant the appropriate permissions to the user or role.\n* For example your need to add PRIVILEGES from Role to correct database\n- Grant USAGE privilege on the \"public\" schema:\n  \n\u003e [!NOTE]\n\u003e Make you following all this step\n\n\u003e [!TIP]\n\u003e If you do 4 first step just jumb to step 5\n\n### FlowWorking \n1. **Create Role**\n```bash\n CREATE ROLE your_role_name WITH LOGIN; \n```\n- `in case you want add password you can change cmd to` \n```bash \nCREATE ROLE your_role_name WITH LOGIN PASSWORD 'your_password';\n```\n2. **Create DataBase**\n```bash \nCREATE DATABASE your_database_name ;\n```\n3. **Grant All Full Access `All Privileges` From Role(User) to Database** \n```bash \nGRANT ALL PRIVILEGES ON DATABASE your_database_name TO your_role;\n```\n4. **Now you need to connet with your database with cmd `\\c` or `\\connect `**\n```bash \n\\c your_database_name\n```\n5. **Grant Schema Public From `Your Database` to `Your Role`** \n```bash \nGRANT ALL ON SCHEMA public TO your_role_name ;\n```\n`AFTER THIS YOUR CAN RUN YOUR CMD AGAIN TO SEE THE MAGIC` \n\n### ** Some Option ** \n1. \n```bash\n    GRANT USAGE ON SCHEMA public TO your_role;\n```\n2. **Grant SELECT privilege on the \"mytable\" table:**\n```bash   \n GRANT SELECT ON TABLE public.mytable TO your_role;\n```\n3. **Grant EXECUTE privilege on the \"myfunction\" function:**\n```bash\n    GRANT EXECUTE ON FUNCTION public.myfunction TO your_role;\n```\n4. **Grant CONNECT privilege on the database:**\n```bash \n    GRANT CONNECT ON DATABASE mydatabase TO your_role;\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphuclam202%2Fdenied-schema-public","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphuclam202%2Fdenied-schema-public","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphuclam202%2Fdenied-schema-public/lists"}