I've tried just about everything to get a user permissions for some relations in postgres. Here's what I've tried:
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO myuser;
GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO myuser;
ALTER DEFAULT PRIVILEGES GRANT ALL ON TABLES TO myuser;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON TABLES TO myuser;
I've changed my pg_hba.cnf to this:
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local replication postgres peer
#host replication postgres 127.0.0.1/32 ident
#host replication postgres ::1/128 ident
I'm sure these commands do something if you fiddle around with them right, but why don't any of these commands do anything anywhere close to what they say?
I'm using python:
>>> conn = psycopg2.connect(host="localhost", port="5432", dbname="mydb",user="myuser", password="mypassword")
>>> cur = conn.cursor()
>>> cur.execute('select count(*) from mytable')
This is the error I'm getting:
>>> cur.execute('select count(*) from public.mytable')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
psycopg2.ProgrammingError: permission denied for relation mytable
I also tried:
ALTER DATABASE mydb OWNER TO myuser;
And a restart, of course.