Justin
Justin

Reputation: 1479

relation *db_name* does not exist postgres

I am trying to set up an ubuntu server with postgres(following digitalocean tuorial).

I ssh'd to the server as root user, from there created a user named 'justin', gave that user admin privileges as instructed. Switched to 'justin', installed python, django, pip, etc and postgres. From here the tutorial said type sudo -u postgres psql , I did this. From here I created a db 'jobzumodb' and user 'jobzumojustin'. I am now trying to grant privileges of that db to this new user: GRANT ALL PRIVILEGES ON jobzumodb TO jobzumojustin; and it returns ERROR: relation "jobzumodb" does not exist. However if I postgres=# \l I see:

                              List of databases
   Name    |  Owner   | Encoding | Collate |  Ctype  |   Access privileges   
-----------+----------+----------+---------+---------+-----------------------
 jobzumodb | postgres | UTF8     | C.UTF-8 | C.UTF-8 | =Tc/postgres         +
           |          |          |         |         | postgres=CTc/postgres+
           |          |          |         |         | admin=CTc/postgres
 postgres  | postgres | UTF8     | C.UTF-8 | C.UTF-8 | 

Anyone know what is causing this?

Note: when I created the db I created it with: CREATE DATABASE jobzumoDB;. And was trying to access it for a long time as 'jobzumoDB' and not 'jobzumodb', before learning the \l command and that it saved as 'jobzumodb' because I did not pass it in quotes. Anyway, not sure if this could be having an effect.

Thanks for any help.

Another edit: upon rereading this I realized I am using the 'postgres' user (I see postgres=#), should I be using the 'jobzumojustin' user and jobzumojustin=# ? Also, I checked to see if 'jobzumojustin' exists, it does, but does not have anything listed under 'list of roles and attributes'.

Upvotes: 0

Views: 234

Answers (1)

steve
steve

Reputation: 6020

I think you forgot the database keyword. It should be:

GRANT ALL PRIVILEGES ON DATABASE jobzumodb TO jobzumojustin;

Upvotes: 3

Related Questions