Remote access to EnterpriseDB PostgreSQL - postgresql

When I install PostgreSQL from BigSQL I can connect from QGIS on other PC to my local PostgreSQL Server (both PCs are on the same local network 192.168.100.0/24). But then I can't install PostGIS because it always says $libdir/postgis-2-3 can't be found (even I copied that folder to libdir path).
When I install PostgreSQL from EnterpriseDB, I install PostGIS very easy. BUT, now I can't access my server remotely (from QGIS).
In both cases I added proper configs to pg_hba.conf and postgresql.conf files (port, listen_address and allowed hosts). Then I restart my server but nothing.
What I'm missing?

Related

pgAdmin4 + WSL2: can't see dbs created with other client

I have followed the steps from here. I successfuly installed both postgres#12.8 in WSL2 and PGAdmin4 on Windows.
Once I start service in WSL and create a server connection in pgAdmin I am not able to see any databases create from the pgAdmin GUI or neither from psql client.
I tried to:
set env variable PGHOST to localhost
editing postgresql.conf to listen_addresses = 'localhost'
connecting pgAdmin server by localhost name and by IP 127.0.0.1
nothing works..
I just ran into the same issue.
If you try to access your DB installed with pgAdmin from WSL 2, make sure you didnt install postgreSQL from Windows, as sudo service postgresql start from WSL will also start the only postgresql service you need.
Basically, it means you need to install postgresql ( sudo apt-get install postgresql) and start it FROM WSL, and then just open pgAdmin from Windows. Do NOT install postgresql directly on Windows as then your pgAdmin might create your DBs into the postgresql service started in Windows and not from the one started from WSL.
Make also sure that pgAdmin is installed for the same user that your WSL 2 uses, if you use it from VSCode for example. Otherwise, for the same reason, your WSL may not be able to find the corresponding DB.
Note that you can list the DB existing on a specific port by running psql -p 5432 -l from WSL ( change 5432 by the port you want to use ).

Postgres ODBC connection issue from Ubuntu VM

I am attempting to use a Zabbix server running on an Ubuntu virtual machine to monitor the Postgres database in our application running on the same host machine (not a VM). To be clear, I am trying to connect from a Linux Ubuntu virtual machine on my computer to Postgres also running not in a VM on the same computer. Zabbix makes use of ODBC, so a preliminary step in the process is to get the ODBC connection to Postgres working correctly. However, I am having a problem.
Steps I have taken:
installed unixODBC via sudo apt-get install unixodbc unixodbc-dev
installed unixODBC driver for Postgres via sudo apt-get install odbc-postgresql
configured odbc.ini to the following:
[test]
Description = test database
Driver = /usr/lib/x86_64-linux-gnu/odbc/psqlodbca.so
Setup = /usr/lib/x86_64-linux-gnu/odbc/libodbcpsqlS.so
Server = 192.168.240.1
User = postgres
Password =
Port = 5432
Database = mydb
Yet when I test the connection via:
isql test -v
I get the following error:
[08001][unixODBC]could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
More notes:
I can successfully connect to Postgres from the admin running on the local (non VM) machine
port 5432 has been completely opened from Windows Firewall on the local machine
telnet to 192.168.240.1 (the network IP of the local machine) on port 5432 succeeds
This all implies that the problem has to do with the ODBC configuration in the Ubuntu VM. I spent several hours searching and trying various things but to no avail. If I can get isql to work correctly, I should be in business, as Zabbix basically sits right on top of ODBC for its database monitoring functions.
Thanks in advance for your help.
I think your configuration options are a little off. Try this:
[test]
Driver = /usr/lib/x86_64-linux-gnu/odbc/psqlodbca.so
Setup = /usr/lib/x86_64-linux-gnu/odbc/libodbcpsqlS.so
Database = mydb
Servername = 192.168.240.1
UserName = postgres
Password =
Port = 5432
Protocol = 7.4
Using Servername instead of Server might be sufficient.
I'd recommend the following steps to getting ODBC and PostgreSQL to play together (ignoring the apt install steps, since you already did these):
sudo odbcinst -i -d -f /usr/share/psqlodbc/odbcinst.ini.template
sudo odbcinst -i -s -l -n test -f /usr/share/doc/odbc-postgresql/examples/odbc.ini.template
sudo nano /etc/odbc.ini
Here's what these do:
Sets up your odbcinst.ini file with the files in the right places.
Sets up your odbc.ini file (for the system).
Edits the system odbc.ini file you created in step 2, where you can replace options to match your needs.
If you do not want the odbc.ini file to be system-wide, you can also limit it to just the user if you call step #2 without the -l parameter. In that case, it'll create or modify a ~/.odbc.ini file, which you can edit for your needs.
The unixODBC folks seem to recommend using odbcinst for setting this stuff up, as it knows where to put the files. Unfortunately, to use it to great effect, you'd need to know where to find the drivers' template files for your driver. The paths I've provided here match the ones for the Ubuntu package.

How to utilize GUI tool of pgadmin using vagrant

I have installed postgresql upon a vagrant ubuntu box and also companied control console with
sudo apt-get --assume-yes install pgadmin3
the tool is installed under /usr/bin
but I can not open pdadmin3 in the virtualbox due to the error
Error: Unable to initialize gtk, is DISPLAY set properly?
Could I possibly do this kind of thing in vagrant virtual box ? Or some work around
Run PgAdmin locally on your main desktop and connect to PostgreSQL on your Vagrant VM over TCP/IP.
The host can connect to guests if properly configured. You'll need to (a) ensure that Vagrant has suitable networking from host to guest, either using NAT and port forwards or using a virtual bridge; (b) ensure that PostgreSQL on the guest listens on all interfaces for TCP/IP connections using listen_addresses in postgresql.conf and (c) ensure that PostgreSQL on the guest is configured to allow connections from remote peers in pg_hba.conf.
Alternately, PgAdmin supports ssh tunnels. If you can ssh to the virtualbox you can configure PgAdmin to ssh to it too, then make a local PostgreSQL connection.
Personally I prefer to instead just use the psql command-line client for PostgreSQL directly on the VM. Way less hassle.

Access embedded postgreSQL database

Can an embedded postgreSQL 9.1.1 database be simultaneously accessed externally by another application?
I installed a separate postgreSQL server on the same machine, but the embedded database doesn't seems to be visible.
The other problem is that I cant find out the password for the user that the application is using to connect to its internal database file.
If you want to connect to a postgresql server, that was installed on you machine by some software you need:
1) Find the cluster directory of the installed postgresql server.
2) Search for the postgresql.conf file in cluster directory. There you will find a port, the server is listening to.
3) Search for pg_hba.conf file in cluster directory. Adding host all all 127.0.0.1/32 trust line to this conf file will allow you to access the server without password.
4) Start the postgres server, specifying the cluster directory from step 1 . (Search for postgres binaryes, installed by the application.). If it is already running - you need to restart it.
5) Connect to the DB using post from step 2 and any postgres login (Try login postgres it is a default one)

How to connect Pgadmin3 to a database on Virtualbox machine?

I have an Ubuntu Server with Postgresql server on Virtualbox machine (which runs on local machine), and Pgadmin3 on local machine.
Now how can I connect with Pgadmin3 to a database on Virtualbox? I am getting
"Server doesn't listen"
Postgres is actually running inside Virtualbox.
Found this out. To make it work, i did:
1) Edited file /etc/postgresql/9.1/main/postgresql.conf , uncommented and edited one line to contain:
listen_addresses = '10.10.4.14,localhost'
Where 10.10.4.14 is address used to access server on virtualbox.
2) Edited file /etc/postgresql/9.1/main/pg_hba.conf , added one line at the end:
host all all 10.10.4.14/24 md5
Note file path in your case might be different if your Postgres version is not the same as mine, or another linux distribution might place those files in other locations.