Reputation: 151
I want to delete a particular database which I have named 'mysitedb' so what I did is I opened the terminal and entered the command 'dropdb mysitedb' then the error 'ERROR: must be owner of database mysitedb' pops up. I know the username and pass for the particular database but don't have a clue on deleting it. I am new to postgresql. be gentle :P
Upvotes: 13
Views: 32953
Reputation: 121881
I want to delete a particular database which I have named 'mysitedb' so what I did is I opened the terminal and entered the command 'dropdb mysitedb' then the error 'ERROR: must be owner of database mysitedb' pops up...
OK - this means you probably don't have the right credentials. You need the username/password of a PostgreSQL user with permissions to delete that database.
NOTE: I know the user who owns it. Also I know the password.
Then who were you logged in as when you got the permissions error?
Anyway, you want the dropdb command:
dropdb -U db_owner_username -i [-h host] mysitedb
Here is the PostgreSQL documentation page.
Here is how to confirm ownership:
SELECT d.datname as "Name",
pg_catalog.pg_get_userbyid(d.datdba) as "Owner"
FROM pg_catalog.pg_database d
WHERE d.datname = 'database_name'
ORDER BY 1;
Upvotes: 3
Reputation: 11439
First switch the cli user:
sudo su postgres
Then connect to your database normally.
Upvotes: 1