Permission denied to create extension “uuid-ossp”

Error: Permission denied to create extension “uuid-ossp”

This error occurs when the user attempting to create the “uuid-ossp” extension does not have the necessary permissions to do so.
The “uuid-ossp” extension is used to generate universally unique identifiers (UUIDs) in PostgreSQL, which require superuser privileges to create.

In order to resolve this issue, you have a few options:

  1. Check if you have the necessary privileges: Verify that you are logged in as a superuser or a user with sufficient privileges to create extensions. In PostgreSQL, the superuser is typically the user named “postgres”. If you are not logged in as the superuser, switch to that user or contact your system administrator to grant you the required permissions.
  2. Grant extension creation privilege: If you already have sufficient privileges but just need the permission to create the “uuid-ossp” extension, you can grant yourself the privilege by executing the following command as a superuser:

    GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO your_username;

    Replace “your_username” with your actual database username.

  3. Ask the system administrator: If you are not a superuser and cannot grant yourself the required privilege, reach out to your system administrator or the person responsible for managing the database server. Explain the situation and ask them to either grant the necessary privileges or create the “uuid-ossp” extension for you.

After resolving the permission issue, you should be able to create the “uuid-ossp” extension without any further problems. Here’s an example of how to create the extension once the permission has been granted:

CREATE EXTENSION IF NOT EXISTS "uuid-ossp";

Leave a comment