Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PostgreSQL - relation doesnt exist error when granting priviliges

Tags:

postgresql

I entered postgres console with sudo and did this:

create user uu with password 'uu';    
create database u_db owner uu;   
grant all privileges on u_db to uu;

Error: Relation u_db doesnt exist.

like image 368
user2349115 Avatar asked Apr 24 '14 17:04

user2349115


1 Answers

You have to use the keyword DATABASE for granting here. So I'm posting you the output from psql in:

postgres=# create user uu with password 'uu'; 
CREATE ROLE
postgres=# create database u_db owner uu;  
CREATE DATABASE
postgres=# grant all privileges on u_db to uu;
FEHLER:  Relation »u_db« existiert nicht
postgres=# grant all privileges on database u_db to uu;
GRANT

However. IMHO through the owner setting of database you don't need to grant extra rights for the user uu.

like image 50
frlan Avatar answered Oct 17 '22 05:10

frlan