Should I remove psql after postgres uninstalling from Mac M1? - postgresql

I am trying to remove postgresql completely from my Mac M1 and then install postgres 13.
There were postgres 14, postgres 11 and postgres 13 installed (simultaneously) on my computer. Due to versions conflict I decided to remove all my postgreses and install version 13 de novo.
To uninstall postgres completely, I followed these recommendations: https://blog.testdouble.com/posts/2021-01-28-how-to-completely-uninstall-homebrew-postgres/
Now I have:
% postgres --version
zsh: command not found: postgres
% which postgresql
postgresql not found
% psql testdb
psql: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: No such file or directory == NO DATABASES
%brew list also shows no postgres installed
but when I do
% psql --version
I see:
psql (PostgreSQL) 14.1
and
% which psql
/opt/homebrew/opt/libpq/bin/psql
So, I have front-end PostgreSQL 14 until now.
Is it normal that psql was not uninstalled with postgres server?
Of course some postgres files also remain in cache, as well as some Docker postgres images.
Should I remove postgresql14.1 client manually? Here I read that in such case after re-installation I can expect Error.
Or, in general: am I missing something that will prevent my computer from correct installing and running Postgres 13 locally and outside of Docker?
Thank you so much in advance for clarification.

Yes, Postgres client (psql) and PostgreSQL server are two separate software. Quite often you need psql in your workstation even if server is running somewhere else.
But if you don't need to connect any PostgreSQL server anymore from your workstation, you can remove psql. No harm done. And it is always easy to re-install if needed.

Related

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

Forgot Password for PostgreSQL 13 db on Mac

I am new to PostgreSQL and before I start learning got stuck in the password;
I have forgotten my password to PostgresSQL 13 path when I use pdAdmin tool.
I use mac. Apologies for basic questions.
I went through multiple articles, videos but I am unable to through different steps.
Steps I did:
Downloaded PostgreSQL 13, logged into pgAdmin, forgot password to PostgreSQL 13 db
Found the "pg_hba.conf" and edited the method from "md5" to "trust"
Steps I am unable to proceed and stuck:
Restart the postgresql service (where and how do I do this? via launching Terminal?)
Start psql session as postgres (how to launch? I searched the psql via search. When I entered "psql -U postgres", its asking for "Database" and "Port (5432)" and "Username". I am unaware to find these"
This is where I am unable to go to next step to use ALTER USER command to reset.
I went through this but when I enter the command "sudo -u user_name psql db_name", its asking for all information above which I don't have knowledge yet. Same as above points where I am getting stuck.
Many thanks in advance.
If you installed Postgres using brew (That's most common case)..
To access postgres
# psql postgres
postgres is the database name, and after this you will be logged into psql and will see postgres db. You can switch to your database as -
\c <your-db-name-here>
To start/stop/restart
brew services start postgresql
brew services stop postgresql
brew services restart postgresql
If you did not install using brew and want to do so -
brew install postgres

PostgreSQL: How to unify versions?

On my Kubuntu machine, locally I was running PostgreSQL in a user-defined directory. Actually, an upgrade from Kubuntu 18.04 to 20.04 provided PostgreSQL12. Actually, I have:
$ psql --version
psql (PostgreSQL) 12.6 (Ubuntu 12.6-0ubuntu0.20.04.1)
$sudo -u postgres psql
[sudo] Passwort:
psql (12.6 (Ubuntu 12.6-0ubuntu0.20.04.1), server 10.16 (Ubuntu 10.16-0ubuntu0.18.04.1))
What do I have to do, to unify this (to version 12) without losing data in the user-defined directory? There are two version 10 packages (PostgreSQL-10 and PostgreSQL-client-10) and the same ones version 12: Is it OK and sufficient to remove the two from 10?
Thank you!
PostgreSQL is free to change how it stores data between versions. So just moving/copying the data directory is highly unlikely to be sufficient.
The simplest solution is to basically dump the data and then load it into the new server. If you start your new server running on a different port and different data directory, you can do this as one-liner.
pg_dumpall -p 5432 | psql -d postgres -p 5433
https://www.postgresql.org/docs/12/upgrading.html#UPGRADING-VIA-PGDUMPALL
If you have a lot of data, and you need to keep your database available during the upgrade then you may wish to look into logical replication.

Parallel versions in PostgreSQL, What do I actually use?

Os - ubuntu 18.04 (bionic)
I have installed postgresql 10 some time ago, and today i install a new version, 12.
I don't mind to throw all the previous data, so i tried to do pg_ctl stop for the old server. I am not able to execute the pg_ctl stop for the old server, because the command not found.
I found where postgres is installed, under /var/lib/postgres and it has two folders, one is 10 and the other is 12. I tried to call pg_ctl from 10/main but it does not appear also there. there is no bin folder there as well.
When I type psql under the postgres user, i get this info:
psql (12.2 (Ubuntu 12.2-2.pgdg18.04+1), server 10.12 (Ubuntu 10.12-0ubuntu0.18.04.1))
I have search for hours in the docs and on the web, but i didn't find info for that.
Can you help me understand what is going on in my machine?
Edit: pg_lsclusters output:
Ver Cluster Port Status Owner Data directory Log file
10 main 5432 online postgres /var/lib/postgresql/10/main /var/log/postgresql/postgresql-10-main.log
12 main 5433 online postgres /var/lib/postgresql/12/main /var/log/postgresql/postgresql-12-main.log
also, i can no longer connect to the new port. I have try to connect to port 5433 with postgres user and my password ( I have changed the pg_hba.conf row to authenticate with md5), but it didn't work.

how launch PSQL if many versions of postgresql

I have ubuntu 18.04 x64 on which i installed PostgreSQL10 and PostgreSQL9.6
When type psql, i have psql for PostgreSQL10.
How to launch psql for PostgreSQL9.6 ?
At finish, i would like to set up PGadmin 3 for those two postgresql instances
There is no need to use psql in version 9.6 for a PostgreSQL 9.6 server. The clients are always downwards compatible.
Best practice is, to use always the latest client, no matter what version of server you are running.