Like both the earlier answers, you have two versions of psql in your host and the default is the older one which is not compatible with the current database version which is 14.
Temporary fix:
- verify the current version & location
bash-4.2$ psql --version
psql (PostgreSQL) 9.2.24
bash-4.2$ which psql
/usr/bin/psql
- Find the location of the version of psql for the current DB.
Usually, its under /usr/psql??/bin , like:
bash-4.2$ cd /usr/pgsql-13/bin
bash-4.2$ ls -ltr|grep psql
-rwxr-xr-x 1 root root 644264 May 13 2021 psql
- Navigate to that location or invoke that psql binary by providing the path, like
bash-4.2$ /usr/pgsql-13/bin/psql --version
psql (PostgreSQL) 13.3
bash-4.2$ /usr/pgsql-13/bin/psql
Pager usage is off.
psql (13.3)
Type "help" for help.
postgres=#
Permanent Fix
If you want the psql of the existing database which is the new version to be default , you can use 'update-alternatives' utility. Like mentioned here:
How do I correct the mismatch of psql version and postgresql version?
This is how I did.
[root@ip-10-211-209-252 bin]# pwd
/usr/bin
[root@ip-xxxx bin]# mv psql psql9
[root@ip-xxxx bin]# update-alternatives --install /usr/bin/psql psql /usr/bin/psql9 1
[root@ip-xxxx bin]# cd /usr/pgsql-13/bin
[root@ip-xxxx bin]# ls -ltr|grep psql
-rwxr-xr-x 1 root root 644264 May 13 2021 psql
[root@ip-xxxx bin]# update-alternatives --install /usr/bin/psql psql /usr/pgsql-13/bin/psql 2
[root@ip-xxxx bin]# update-alternatives --config psql
There are 3 programs which provide 'psql'.
Selection Command
-----------------------------------------------
*+ 1 /usr/pgsql-13/bin/psql
2 /usr/bin/psql
3 /usr/bin/psql9
Enter to keep the current selection[+], or type selection number: 1
[root@ip-xxxx bin]#