pgAdmin4 SCRAM authentication libpq 10 - postgresql

First of all - I'm not an expert (to say the least).
I want to set up a PostgreSQL database on my Raspberry Pi 4, with Ubuntu Desktop 22.04 LTS and pgAdmin4, but I got stuck.
After running pgadmin in Python Virtual Environment and going to 127.0.0.1:5050, login page appears, all seems fine, until I try to set up a new server. After providing server name and address alert appears: "Unable to connect to PostgreSQL server: SCRAM authentication requires libpq version 10 or above"
Modifying password-encryption and METHOD in pg_hba.conf and postgresql.conf to md5 did not help.
Postgres 14, pgAdmin 4 v 6.10, libpq-dev is already the newest version (14.4-1.pgdg22.04+1).
Any suggestions?

I have tried many combinations of changing passwords, configs and restarting. Here's what worked:
I have removed libpq.so from usr/lib/aarch64-linux-gnu (libpq.so.5 and libpq.so.5.14 are left alone)
Changed all METHODs in pg_hba.conf to trust & restart postgres
Changed password-encryption in postgresql.conf to md5 & restart postgres
Reset password for user postgres (which might have been redundant due to "method/trust") & restart postgres
...and it works.
Thank you!

Related

postgresql - psql always goes to port 5432, even when 2 versions of postgresql are running

I have 2 versions of postgresql running on Suse SLES, 9.6 and 10.7. The 9.6 version is running on port 5432, and 10.7 is running on port 5433. All the executables for each version are in the directory for that version, including psql.
If I execute the default psql, I get psql for version 9.6.3:
psql (9.6.3)
However, when I try to execute psql for version 10.7:
/usr/pgsql-10/bin/psql
it opens the version for 10.7, but reading from postgresql 9.6.3:
psql (10.7, Server 9.6.3).
If I try to give it the port number for 10.7:
/usr/pgsql-10/bin/psql -p 5433
it demands a password, but rejects the password for the user postgres that I know works in other contexts.
I have spent considerable time searching for an answer to this question, and I am sorry I have not found anything helpful. Thanks for any suggestions!
There are two issues in play here.
1)
I su to postgres: su - postgres This requires a password, and the password that works here, does not work when psql wants/demands a password.
The OS postgres user is not the same as the database postgres user.
On a fresh install the database postgres user does not have a password. Generally speaking the auth method for the user is set to either trust, ident or peer. See here pg_hba.conf what they mean. The key to a solution is to modify the pg_hba.conf to allow the user to connect in order to be able to create a password. The easiest way is to set a connection method, best practice local(socket) to trust. Then you can connect without a password and create one.

pgadmin4 can't connect to postgresql 14

I've installed postgresql 14 and pgadmin4 on Ubuntu 20.04. I set a password with sudo passwd postgres and restarted postgresql I've modified the METHOD settings in /etc/postgresql/14/main/pg_hba.conf to be trust. But pgadmin4 refuses to connect with this message:
This used to be all it took to get pgadmin4 to connect.
Is there something new in Postgresql 14 that has to be done?
Thank you, I was going crazy trying to resolve this issue for the last 3 days until I hit this post.
I recently installed PostgreSQL 14 on Ubuntu 20.04 and was trying pgAdmin 4 v. 6.7 and was not able to even create a server without having an INTERNAL SERVER ERROR message. The issue was that when installing PostgreSQL I simply used the same Linux root user password and did not specify a password for the postgres user as you mentioned in the line:
psql -c "ALTER USER postgres WITH PASSWORD 'secure_password_here';"
Thank you

postgres password error : Please enter the password for the user 'postgres' to connect the server - "PostgreSQL 13"

I having issue connection to postgres, I am installing at windows 10 via the EDB installer (version 13.2) . I follow all the steps it install fine however when I try to enter the default database using pgadmin it I always get stuck at this error :
Please enter the password for the user 'postgres' to connect the server - "PostgreSQL 13"
during instalation postgres ask me to specify my master Password. then when instalation finish and I open my pgadmin it again ask me to enter the master password so I did and I was able to successfully login but when I try to open the default database that when it ask me to enter password for posgres user , I try to use the my master password but it did not work
I installed and uninstall it many time with no success. I also tried this solution so I did change the Method in pg_hba.config from scram-sha-256 to trust however when I executed this command psql -U postgres it again asked me for the password
any help please
You made the same mistake I did: you installed pgAdmin4 without installing postGreSQL server itself. The server installation does indeed set the Master password and the postgres user password at the same time, as the commenters were trying to point out. JUST installing pgAdmin sets a master password for the Admin environment. I don't really understand how there's not a more useful error for trying to connect to a server instance that doesn't actually exist, but here we are.
try it. it resolves for me
step 1
step2

Create new local server in pgadmin?

I have PostgreSQL 11 and PGadmin 4 installed on windows. Currently I'm connected to a AWS server which hosts all of my data.
I want to create a local server (localhost) as a testing environment where I can experiment. I can't seem to do it though, and the other similar questions on stack don't help. Here's what my process is:
in pgAdmin, right click 'Servers' and go Create>Server
On the 'Create - Server' pop up box, i type in Name: Localserver. For 'connection' I type localhost. Port I leave as default '5432', db: postgres, username: postgres password: empty
click save.
however, I get an error:
Unable to connect to server:
could not connect to server: Connection refused (0x0000274D/10061)
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432?
could not connect to server: Connection refused (0x0000274D/10061)
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
What should I do? I am the admin if that makes a difference.
As a new Postgres user, I did not understand how to make use of Postgres on Ubuntu. So I'm just going to chime in and help out other newbies who perhaps cannot figure out how to work with Postgres on Linux. If you're using Windows, steps should be similar.
Before you get to using PgAdmin, a bit of configuration is required. Most will happen in your terminal at first.
Open a terminal using Ctrl + Alt + T if you're on a PC. Or just pres ALT + F1 and begin typing Terminal.
Let's start with the basics first and make sure you have proper
installation.
1. Installing Postgres Latest
1.1 update the system software packages
sudo apt update
1.2 install latest version of PostgreSQL from default Ubuntu repositories
sudo apt install postgresql
the installer will create a new PostgreSQL collection of databases
that will be managed by a single server instance
Default data directory : /var/lib/postgresql/your-version/main
Configurations files : /etc/postgresql/your-version/main
2. Checking if Postgres Service is Installed
2.1 Check if Postgres is Active
sudo systemctl is-active postgresql
You should see : active
2.2 Check if Postgres is enabled
sudo systemctl is-enabled postgresql
You should see : enabled
2.3 Check Postgres Service status
sudo systemctl status postgresql
You should see : active (exited) marked in green
2.4 Check if Postgres is ready to accept connections
sudo pg_isready
You should see : /var/run/postgresql:5432 - accepting connections
3. Configuring Postgres Authentication
3.1 Opening the pg_hba.conf as SUPERUSER
sudo code --user-data-dir=~/root /etc/postgresql/13/main/pg_hba.conf
I'm using visual studio code so for me code is vsc codename. If you're using vim or sublime just replace code with your text editor name.
3.2 Configuring pg_hba.conf
Notes: you shouldn't need to change anything here, just make sure your
configuration files matches the following lines :
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
Hit save and close.
3.3 Restart Postgres Service
sudo systemctl restart postgresql
4. Create NEW Server
For me, this is where all my confusion was. Before you use PgAdmin,
you need to create a server in your terminal, then you can connect and
manager it with PgAdmin just like you would with PhpMyAdmin. It's
actually easier.
4.1 Access the PostgreSQL database shell
sudo su - postgres
psql
You will then see this : postgres=#
4.2 Creating new server and user
postgres=# create user bob with superuser password 'admin';
That's how you create new user and server in Postgres. Let's move on to PgAdmin.
5. Installing pgAdmin4
5.1 Add public key for the repository
curl https://www.pgadmin.org/static/packages_pgadmin_org.pub | sudo apt-key add
Notes : if you don't have curl your Ubuntu will give you the command to install it
5.2 create the repository configuration file
sudo sh -c 'echo "deb https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/$(lsb_release -cs) pgadmin4 main" > /etc/apt/sources.list.d/pgadmin4.list && apt update'
5.3 install pgAdmin4
sudo apt update
sudo apt install pgadmin4
5.4 run the web setup script installed with the pgadmin4 binary package
sudo /usr/pgadmin4/bin/setup-web.sh
It will asks you for your email address and password. This email and
password is required to login to the PgAdmin4 web interface
6. Accessing pgAdmin4 Web Interface
6.1 Open your favorite browser
type in the address of the PgAdmin web interface. It usually looks like this
http://127.0.0.1/pgadmin4
Note : After installation the web setup script will tell you exactly
where to access the web interface.
When you see the login screen, enter the email and password you've chosen during the web setup script.
6.2 Adding New Server Connection
6.2.1 Click on Add New Server
6.2.2 Under General tab enter a name for your server. ANY name you would like, it doesn't matter. You could enter PgServer1 or whatever. Don't change anything else.
6.2.3 Switch to Connection Tab
Hostname/ Address : localhost
Port : 5432
Maintenance database : postgres (always)
Username : **bob** (the username youve chosen at 4.2)
Password : admin (or any password you chose at 4.2)
Hit Save.
Voila! You should be connected successfully. If not, just open terminal and create a new user like we did at 4.2
Notes : to create databases is very easy just right click on your
servername
create > databases
Useful Resources & Tutorials
PostgreSQL Fundamentals : Queries and the likes
PostgreSQL & JSON : useful for dealing with JS apps
PostgreSQL & Nodejs : Create realtime apps with nodejs and socket.io
More PostgreSQL Nodejs
https://github.com/supabase/realtime
https://whatsyourssn.com/posts/real-time-app-socket-postgresql/
UPDATE 2023
While following my own tutorial I ran into certificate issues at step 5 when I tried to create the repository file. The full error I was getting was this.
I want to post the solution that worked for me here.
This is probably one of two things.
You have set up a Postgres server, but have not adjusted listen_addresses in your postgresql.conf file, or
You have not set up a Postgres server on your local machine. ("Create Server" is a bit misleading, it should probably be "Create Server Connection".)
Usually a “connection refused” error indicates that the database server is either 1) not running, or 2) configured in such a way that it is not listening to the right port or IP address. Be sure to check ps -ef to see if Postgres is running, and also look at postgresql.conf to see if port and listen_addresses are set properly.
make sure the postgres service is running.
example in Linux : systemctl enable postgresql.service
Why? Attempting to connect to the server that is not running.
Action: Start your PostgreSQL server.
The path in the command below points to the data directory configured during the installation of PostgreSQL. Run this in Windows cmd.
pg_ctl -D "C:\user\PostgreSQL\data" start
>server started
After this go to pgAdmin and follow the initial steps as in question.
Create Server
Under General: Name: mytestServer
Under Connection: Hostname: localhost, Password: yourPassword,
keep other settings as default
Hit save
If you haven't, then first install the Postgres server on your machine. For windows, this is the currently active link for downloading the installation package: https://www.postgresql.org/download/windows/
As other answers here pointed out, PgAdmin is only a interface for using the Postgres server. Once you install the server locally, you'll be able to see the server on the left hand side pane after restarting PgAdmin.

Openbravo - Connecting pgadmin with postgresql database in Ubuntu

I have installed Openbravo ERP 3.0 in Ubuntu 12.04(LTS). After completed the installation I tried to connect with postgresql database using pgadmin 9.1. I gave all the details as mentioned in this link: http://wiki.openbravo.com/wiki/Installation/Appliance/Openbravo.
Also I have changed the config file settings like listen_addresses="*". I got this error after I click "Ok" button
Could anyone give suggestion to fix this error? Thanks in advance.
Actually the problem comes because of not mentioning the local cluster or data area for PostgreSQL. To do this after installing Openbravo, need to give this command in terminal
psql -d openbravo -U tad -h localhost -p 5932
Finally give the PostgreSQL configuration details as mentioned in this link
It works fine now...
To be able to reach the server remotely you have to add the following line into the file: /var/lib/pgsql/data/postgresql.conf:
listen_addresses = '*'
PostgreSQL, by default, refuses all connections it receives from any remote address. You have to relax these rules by adding this line to /var/lib/pgsql/data/pg_hba.conf:
host all all 0.0.0.0/0 md5
This is an access control rule that lets anyone login from any address if a valid password is provided (the md5 keyword). You can use your network/mask instead of 0.0.0.0/0 to only allow access from certain IP addresses.
When you have applied these modifications to your configuration files, you will need to restart the PostgreSQL server.
/etc/init.d/postgresql start
Now, you will be able to login to your server remotely