title: Grant privileges to a specific table with PostgreSQL (relation "*" does not exist)
body: <p>I am trying to grant read only access to a user on a few tables.</p>
  
  <p>Here is what I have done so far:</p>
  
  <pre><code>postgres=# CREATE ROLE myuser LOGIN PASSWORD 'mypassword';
  CREATE ROLE
  postgres=# GRANT CONNECT ON DATABASE mydb TO myuser;
  GRANT
  </code></pre>
  
  <p>The tests I have tried (which does not work):</p>
  
  <pre><code>postgres=# GRANT SELECT ON TABLE mytable TO myuser;
  ERROR:  relation "mytable" does not exist
  postgres=# GRANT SELECT ON TABLE mydb.mytable TO myuser;
  ERROR:  schema "mydb" does not exist
  postgres=# GRANT SELECT ON TABLE public.mytable TO myuser;
  ERROR:  relation "public.mytable" does not exist
  postgres=# GRANT SELECT ON TABLE mydb.public.mytable TO myuser;
  ERROR:  cross-database references are not implemented: "mydb.public.mytable"
  </code></pre>
  
  <p>The resources I relied on:</p>
  
  <p><a href="https://tableplus.io/blog/2018/04/postgresql-how-to-create-read-only-user.html" rel="noreferrer">https://tableplus.io/blog/2018/04/postgresql-how-to-create-read-only-user.html</a>
  <a href="https://www.postgresql.org/docs/current/sql-grant.html" rel="noreferrer">https://www.postgresql.org/docs/current/sql-grant.html</a></p>
  
  <p>I do not understand what is missing because I followed these articles, my logic would be to specify in which database is the table but this is not mentioned.</p>
  
  <p>I have also already checked for similar issues on StackOverflow, but the steps are the same as the resources I mentioned above.</p>
  
  <p>(I don't know if it's relevant but I use postgresql 9.6)</p>
  
  <p>Help would be really appreciated!</p>
  
  <p><strong>============</strong></p>
  
  <p><strong>EDIT:</strong> when I run the \d command</p>
  
  <pre><code>postgres=# \d
  No relations found.
  
  postgres=# select current_database();
   current_database 
  ------------------
   postgres
  (1 row)
  </code></pre>
  
  <p>I tought the postgres user had all the privileges, but maybe I should connect with my own user ?</p>