I need to share my database from PostgreSQL in my PC with my colleagues in the same office (in the same network). I did some research but I still have some questions regarding it.
A bit background for myself: I have been using PostgreSQL independently for a while and have created a bunch of useful DBs, and now need to share it with others. So I am familiar with PostgreSQL's usage and its syntax, but for its database management, I am still fairly new... My PostgreSQL version is 10.6 and I'm working on Windows.
During my initial research, I found that this post is helpful to my question, but I need more clarification on it. The answer to the above post mentioned:
The user needs access to the database, obviously:
GRANT CONNECT ON DATABASE my_db TO my_user;
And (at least) the USAGE privilege on the schema:
GRANT USAGE ON SCHEMA public TO my_user;
So here goes the 1st question: where should I run these code? Suppose I am on pgAdmin and in the database I would like to share, should I just open a Query Tool and run the syntax there?
Secondly, is the user name (such as my_user
used in above code) the same one as we used for our own superuser name? i.e. If my superuser name is just postgres
(I believe it is the default during installation), if there's someone wants to grant me access to his DB, he just use postgres
for my_user
?
Lastly, if there's an user outside of my office, how to grant remote access then?
Additionally, I've added my pg_hba_conf here:
# TYPE DATABASE USER ADDRESS METHOD
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
host replication all 127.0.0.1/32 md5
host replication all ::1/128 md5