PostgreSQL: After Removing PostgreSQL 12 psql version 12.2 still persists - postgresql

With Ubuntu Upgrade to Ubuntu 20.04 Postgres was updated to 12.
I did remove Postgres 12 with
sudo apt-get purge postgresql-12
to go back to Postgres Version 9.3 (I know it's outdated and upgrade highly recommended and it's planned within a few weeks)
But I noticed psql is still on version 12.2.
How can I revert psql version to 9.3?

Related

How to upgrade postgresql using brew postgresql-upgrade-database

It appears there is a newish command brew postgresql postgresql-upgrade-database that can be used to assist in the upgrade a postgresql database group. How do I use it to upgrade between major versions of postgresql, e.g. from 11.8 to 12? Also between minor versions e.g. 11.6 to 11.8?

Upgrade psql on Mac OS - Mismatching client and server versions. Some psql features might not work

I have just upgraded to PostgreSQL 10.11 on macOS using Homebrew and I am now getting the following message:
psql crmpicco
psql (9.6.16, server 10.11)
WARNING: psql major version 9.6, server major version 10.
Some psql features might not work.
Type "help" for help.
crmpicco=#
There's plenty of advice online for resolving this for Debian and Ubuntu, but nothing for MacOS/Homebrew.
How can I update psql locally to get rid of this message?
I suspect that you didn't run upgrade command for brew Postgres after upgrade to new version:
brew postgresql-upgrade-database
incase it didn't work, there is a gist online for home-brew Postgres upgrade, its for old version but still valid in how to upgrade in mac:
migrate_postgresql_database

How can i upgrade postgresql version without dump and restore the DBs?

in the past i upgraded postgresql server from 9.3 to 9.6 version in this way:
(dump all the DBs)
apt-get install postgresql-9.6 postgresql-contrib-9.6
pg_dropcluster 9.6 main --stop
pg_upgradecluster 9.3 main
pg_dropcluster 9.3 main
And then, i relaunched the initdb, recreated the databases and restored with the previous dumps.
now i want to upgrade from 9.6 to 10 or major.
Is there a way to do this without dump all the DBs and then restore them?
Thanks in advance
Duplicate: How to upgrade PostgreSQL from version 9.6 to version 10.1 without losing data?

Is it possible to upgrade PostgreSQL 9.2 directlly to Postgres 11.1 over CentOs 7 + cPanel?

I need PostgreSQL 11.1, but my CentOs 7 + cPanel shows:
[root#hwsrv-359572 csf]# postgres --version;postmaster --version;
postgres (PostgreSQL) 9.2.24
postgres (PostgreSQL) 9.2.24
[root#hwsrv-359572 csf]#
I can UPGRADE from 9.2 to 11.1?
Are the differences between 9.2 and 11.1 very, very big and is it required to install PostgreSQL 11.1 completely?
Maybe some links symbolics is sufficient?
by example 9.2 use:
/var/lib/pgsql/data
but from version 10.x PgSQL use:
/var/lib/pgsql/{version}/data
is very hard/impossible
do upgrade from 9.2 to 11.1
and then no lost the GUI of cPanel + PhpPgAdmin?
is best do a installation fresh of Postgres 11.1?
when I do this,
cPanel does not detect Postgres and more:
GUI PhpPgAdmin interface is lost in cPanel.
I believe the best option is to upgrade,
because cPanel includes only Postgres 9.2
However, I can't find how to upgrade from 9.2 to 11.1

Upgrade Postgresql 8.3 database file to 8.4

I upgraded my Ubuntu 8.04 To Ubuntu 10.04. Unfortunately, the upgrade process also updated the Postgres 8.3 install to a Postgres 8.4 install. My feeling is that although database engine binaries have been updated, the database itself was not migrated, hence it can not be loaded by the 8.4.
Since the 8.3 data format is not compatible with 8.4 format, altering postgresql.conf is not enough, nor can I use pg_dump with my 8.4 install.
I need a way to upgrade my previous base from 8.3 to 8.4, with no access to a 8.3 engine, only a 8.4.
Any clue?
The postgres packages in Debian, and hence, Ubuntu, has a very clearly defined way of upgrading from one Postgres version to another. The procedure is documented in /usr/share/doc/postgresql-common/README.Debian as follows:
Default clusters and upgrading
------------------------------
When installing a postgresql-X.Y package from scratch, a default
cluster 'main' will automatically be created. This operation is
equivalent to doing 'pg_createcluster X.Y main --start'.
Due to this default cluster, an immediate attempt to upgrade an
earlier 'main' cluster to a new version will fail and you need to
remove the newer default cluster first. E. g., if you have
postgresql-8.2 installed and want to upgrade to 8.3, you first install
postgresql-8.3:
apt-get install postgresql-8.3
Then drop the default 8.3 cluster:
pg_dropcluster 8.3 main --stop
And then upgrade the 8.2 cluster to 8.3:
pg_upgradecluster 8.2 main
The best time to do this is before ugrading to a version of Ubuntu where the version of Postgresql you're currently running has been removed, i.e. in this example, while on a version of Ubuntu that has the possibility to install both Postgres 8.3 and Postgres 8.4. In my case, I went from jaunty to karmic, upgraded 8.3 to 8.4 and then went from karmic to lucid.
The upgrade process as described above is very smooth. The *pg_upgradecluster* command will stop the old version, migrate data, then start the new version on the same port as the old version, finally starting the old version on a new port.
If you did not migrate your 8.3 postgres data before moving to an Ubuntu version that lacks postgres 8.3, migrating is still simple. Start by adding the karmic ubuntu repository to /etc/apt/sources.list:
deb http://archive.ubuntu.com/ubuntu/ karmic main restricted universe
Install postgresql-8.3:
apt-get update && apt-get install postgresql-8.3
Drop your 8.4 cluster. Warning: This will remove data in your postgresql 8.4 installation if you have any. But if you're only doing this because you need to upgrade your 8.3 to 8.4, you will have no data in your 8.4 cluster.
pg_dropcluster 8.4 main --stop
And then upgrade the 8.3 cluster to 8.4:
pg_upgradecluster 8.3 main
Finally, remove the postgresql-8.3 package, and remove the jaunty-line from /etc/apt/sources.list, then run apt-get update again.
As usual, taking a backup of your postgres directories before doing any of the above is always a good idea.
You'll have to install PostgreSQL 8.3 in temporary location from source, copy your old data there, start Pg, dump it's data using pd_dumpall and then import this data to new Postgres.
It's impossible without installing Pg 8.3.
Make sure you backup everything before you try anything.
There is the pg_migrator project which I think will do that for you, though I'm not sure whether it needs to 8.3 applications or source code.