Reputation: 51
I'm pretty new to using postgresql and seemed to have installed two versions that are running at the same time. Both 12 and 14.
Below is the list of commands that I've run, and the results they've yielded.
From WSL-2 Ubuntu 20.04 CLI
➜ which psql
/usr/bin/psql
➜ pg_config --version
PostgreSQL 14.4 (Ubuntu 14.4-1.pgdg20.04+1)
➜ psql --version
psql (PostgreSQL) 14.4 (Ubuntu 14.4-1.pgdg20.04+1)
From psql
=# SHOW server_version;
server_version
------------------------------------
12.11 (Ubuntu 12.11-1.pgdg20.04+1)
(1 row)
=# SELECT version();
version
-------------------------------------------------------------------------------------------------------------------------------------
PostgreSQL 12.11 (Ubuntu 12.11-1.pgdg20.04+1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0, 64-bit
(1 row)
I've have some persistent issues with my odoo 15 db and think this may be the cause but am unsure.
Any recommendations on how to transition from 12.11 server to 14.4 server and remove 12.11 server would be greatly appreciated.
Upvotes: 1
Views: 1571
Reputation: 9660
I also ended up with two Postgres servers with different versions following a major Ubuntu upgrade. It turns out that there is a less radical way to get rid of the old version:
pg_dumpall -h localhost -U postgres -W > all_pg.sql
. This will ask for the postgres
user's password as many times as there are databases in the cluster.sudo pg_dropcluster --stop 14 main
sudo pg_upgradecluster 12 main
sudo pg_dropcluster 12 main
sudo apt-get purge postgresql-12 postgresql-client-12
In summary, there is no need to sudo apt purge
all Postgres packages and then reinstalling the most recent one.
Upvotes: 0
Reputation: 51
Thanks to all the above for the help!
Commands I ran to fix on Ubuntu 20.04 / Windows-11 WSL-2:
pg_dumpall > export.sql
sudo apt-get --purge remove postgresql\*
sudo apt-get install postgresql-14
(or -version preferred)sudo -u postgres -i
psql
CREATE ROLE username superuser
ALTER ROLE username WITH LOGIN;
\password username;
\q
exit
Upvotes: 2