1

I have a problem with my database. I installed postgreSQL 9.5 on my Ubuntu server. I changed the postgresql.conf file to allow binding the postgreSQL server to the localhost. This allows me to run pgAdmin and connect to my database by forwarding also the port 5432, where I run my postgreSQL.

The problem I am experiencing is that I only see the default table 'postgres', but not my newly created one 'games' (I created this table by running create database games with the postgres user connected to the server).

enter image description here

And here is my screen shot of the pgAdmin application with all the property value I use to connect to my server.

enter image description here

As you can see from the first picture I use the same permissions as for the postgres database - it is blank, which should grant access to everyone. I know I have to change that later and limit it to the postgres user I have, but for now I will let it that way. Once I manage to see my 'games' database, then I will start to tighten the security more.

UPDATE I granted all access to the database 'games', which is visible right on the third screen shot down. The access privilege is different. This did not help me, I would still not see the database, when connecting to the server with pgAdmin. A saw someone had a similar problem and run the right click on the server and clicked 'New database'. This seems created a new database, because as you can see from the pgAdmin, the application manage to find the score table I create inside pgAdmin. The reason I believe this is the case is, because running the same SQL connected to the server postgres=# select * from score; results in ERROR: relation "score" does not exist LINE 1: select * from score;.

enter image description here

Jernej K
  • 1,602
  • 2
  • 25
  • 38

3 Answers3

3

I manage to find the problem. One of my problems was that I had (unaware of that) installed a postgreSQL server on my machine. Seems I installed it with my pgAdmin install. So everytime I would connect to my server, I would establish a connection to my localhost server and not my remote server. So I just uninstalled the server and installed only the pgAdmin client.

The second problem I had was that the file /etc/postgresql/9.5/main/pg_hba.conf had to be changed. So I run:

sudo vi /etc/postgresql/9.5/main/pg_hba.conf

and changed the line

# Database administrative login by Unix domain socket local all postgres peer

to

# Database administrative login by Unix domain socket local all postgres md5

Once that was changed, I had to restart the configuration by executing:

sudo /etc/init.d/postgresql reload

I would also point out that it is important to have postgres user as a unix and DB user with same passwords. I found all this information here.

ankuranurag2
  • 2,300
  • 15
  • 30
Jernej K
  • 1,602
  • 2
  • 25
  • 38
  • For me, it was having different passwords for the postgres user in the database to the postgres account it was running under. Thanks. – Deepstop Sep 16 '22 at 13:52
0

Try granting access privileges explicitly for your new table.

I believe a blank access privileges column means the table has DEFAULT access privileges. The default could be no public access for tables, columns, schemas, and tablespaces. For more info: http://www.postgresql.org/docs/9.4/static/sql-grant.html

obi1
  • 314
  • 2
  • 6
  • I tried that, but it did not do any good. I executed 'postgres=# grant all privileges on database games to postgres;' and now the games database has access privileges '=Tc/postgres + postgres=CTc/postgres'. And I still only see the postgres database, but nothing else. – Jernej K Mar 22 '16 at 02:36
  • If I do the same as [here](http://stackoverflow.com/questions/15754010/some-postgresql-databases-not-visible-through-clients-like-navicat-or-pgadmin), the database opens. So I am trying to figure out it is the result of having 'pg_database.datistemplate' set to 'true'. – Jernej K Mar 22 '16 at 02:45
  • After I used 'New database' the 'games' database is always visible. But it seems like it is not the same 'games' database as the one listed, when I execute '\l+'. I do not see my comment 'database for storing game scores for various games' like it is printed with '\l+'. – Jernej K Mar 22 '16 at 03:03
  • Maybe I should change something in this file '/etc/postgresql/9.5/main/pg_hba.conf'. I have not clue what else I should try. – Jernej K Mar 22 '16 at 03:17
0

If only the 'postgres' database is visible and your newly created database is not showing up, here is the solution: Right-click on 'postgresql' and open the query tool as shown in

enter image description here

. Then, in

enter image description here

click on 'New Connection,' select your database, click on 'Save,' and confirm. In the query screen, write this query:

UPDATE pg_database SET datistemplate='false' WHERE datname='database_name';

replace 'database_name' with your actual database name, and execute the query. After that, refresh your databases, and it should appear.