PostgreSQL seems to be using an old version after update - postgresql

I uninstalled my PostgreSQL because I'm trying to use version 9.1.9. I tried reinstalling it. It successfully installed from what I can see.
However, when typing in psql --version on the command line, I get that it is still using version 9.0.10
How can I make it use the new version?

psql is the command line interface and its version can be independent of the Postgres server.
To get the version of the server software run SELECT version() against the database you are connected to (from within psql). Though it is possible to interact with different versions, some obvious limitations apply. I suggest you uninstall the outdated psql as well and use the version matching the server.

If you're running this on a UNIX/Linux system the problem is likely to do with where psql is being called from. It doesn't sound like the old version got removed and you're still calling it when you run psql. Try running this:
which psql
That will tell you the full path of what gets invoked when you run just psql. To see if there are other instances of psql installed on your system try running:
sudo updatedb
(you'll need to put in your password here). And then:
locate psql
Your system likely uses some kind of package manager, which controls which packages are installed. For example, Ubuntu/Debian use dpkg, Redhat uses yum, you may be using something like fink or macports if you are using OSX.

Related

psql binary file missing- is there any way of replacing it without unistall/reinstall of Postgres?

I've had as few issues trying to upgrade postgresql-server. I've reverted back to the older version now (9.0.3) and the service is running and accessible via pgadmin/other gui tools.
However, I can't access it via the psql command (as user postgres). This may be possibly because the psql binary seems to be missing. I feel this may have happened when I uninstalled a version of postgres that I had intended to revert to.
I can't reinstall version 9.0.3 because the repo is no longer valid.
Is there any way I can install only the psql binary file and nothing else. I was considering copying the psql binary file from another server, although because the other servers have different versions of postgresql, I'm not sure if this is a good idea (?)
I think psql binaries didn't disapear from your system.
It's just that you had symbolic links from /usr/bin to your 9.0.3 binaries.
When you installed a newer version, this links where replaced to point to the new version and when you uninstalled it, they were dropped.
Try locate to find your binaries. Then you would be able to recreate your symbolic links in /usr/bin.
If you want to try 9.0.3 - you can always build it from source:
https://www.postgresql.org/ftp/source/v9.0.3/
But many distros package pqsl-client seperate from the server and you can use a newer version of psql instead (or at least try).
There are also archives of almost any distro out there and you could fetch that single rpm/deb packge from there.

pgadmin4 : postgresql application server could not be contacted.

I have installed PostgreSQL 9.6.2 on my Windows 8.1. But the pgadmin4 is not able to contact the local server. I have tried several solutions suggested here in stackoverflow, tried to uninstall and reinstall PostgreSQL 9.6.2 , tried to modify the config.py, config_distro.py, and delete the files in Roaming folder,i tried standalone pgadmin4 installation, but no success.However, in my local machine i am able to access the server using psql.exe and log as as superuser (postgres user). Can you please suggest any possible solutions to starting/running pgadmin4 ? Thank you.
I found the same issue when upgrading to pgAdmin 4 (v1.6). On Windows I found that clearing out the content inside C:\Users\%USERNAME%\AppData\Roaming\pgAdmin\sessions folder fixed the issue for me. I believe it was attempting to use the sessions from the prior version and was failing. I know the question was marked as answered, but downgrading may not always be an option.
Note: AppData\Roaming\pgAdmin is a hidden folder.
Start pgAdmin 4 as administrator.
Do the following steps:
Right click pgAdmin 4 icon
Select "Run As Administrator"
I had the same issue on Windows 10, with a new installation of PostgreSQL 10.
I solved it by including the path C:\PostgreSQL\10\bin ({your path to postgresql}\bin) to system environment variables.
To access environment variables: Control Panel > System and security > System or right click on PC, then > Advance system settings > Environment variables > System variables > Path > Edit.
I've been dealing with this for awhile (frustrating). So much that I have instructions on my desktop consolidating all of these ideas. Here is my magic combination to the solution:
Delete from App Data C:\Users\%USERNAME%\AppData\Roaming\pgAdmin
Add to Path Variables C:\Program Files\PostgreSQL\9.6\bin (I actually added it to both user and system)
Right click and start as admin.
You don't have to do this every time but when it gets out of wack try these steps.
What finally worked was downgrading to pgadminIII-v.1.22:
It seems in most of the cases Postgres trying to use information from previous sessions to find/connect the server and failing. Clearing out the previous session info helped me, it is a combination of 2 already mentioned answers above:
Navigate to Postgres session's folder
C:\Users\YourUsernameOrAdmin\AppData\Roaming\pgAdmin\sessions
Delete all the data from this folder.
Start PgAdmin in administrator mode.
Cheers!
if you are using Mac OS X here is a fix:
Open terminal and run this command
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log restart
and for other OS just restart your Postgresql server, it will solve
Then start pgAdmin4, it will start as normal
Share or comment if saved someone
Deleting the contents of C:\Users\%USERNAME%\AppData\Roaming\pgAdmin directory worked for me!
I had same issue on windows. I had v1.6 installed as well as v2.0. Uninstalling v1.6 allowed me to login.
I had the same problem, but running it as an admin worked.
Have you recently installed a new version of pgAdmin ?
This issue (and the misleading message) is simply due to the fact that old versions of pgAdmin are unable to read the settings saved by a newer version of pgAdmin !
Make sure you're starting the right version of pgAdmin (your shortcuts are likely to point to the old version !) and/or uninstall the old version: the upgrade wizard doesn't do it for you !
Deleting contents of folder C:\Users\User_Name\AppData\Roaming\pgAdmin\sessions helped me, I was able to start and load the pgAdmin server
I had the same issue on the macosx and I renamed .pgadmin (in /users/costa) to .pgadminx and I was able to start pgAdmin4.
In Windows Just go to this path and clear it
,that works !!
C:\Users\%USERNAME%\AppData\Roaming\pgAdmin
I was able to solve the problem by changing the pgAdmin web interface port.
I believe this problem occurred on my computer because I have several other services consuming webs ports like qBittorrent, IDEJetbrains, etc.
Right-clicking on the pgAdmin logo near the clock is possible to configure it.
I Fixed it in windows 10 just running pgAdmin 4 as Run as Administrator .
If you use older postgresql version like 9.x and its services is running,PgAdmin 4 confused which server is base database.
So stop the service older version or new one.Run PgAdmin 4 as Administrator
Its worked for me
This is often a firewall problem. The firewall log then shows dropped packets between 127.0.0.1: and 127.0.0.1:, where the latter is the port shown in the Browser to get no connection with. This means, that the connection between pgAdmin client (high_port_1) and pgAdmin server (high_port_2) is blocked. Check your firewall log and if you find dropped packets like described, adapt your firewall settings accordingly.
If none of the methods help try checking your system and user environments PATH and PYTHONPATH variables.
I was getting this error due to my PATH variable was pointing to different Python installation (which comes from ArcGIS Desktop).
After removing path to my Python installation from PATH variable and completely removing PYTHONPATH variable, I got it working!
Keep in mind that python command will not be available from command line if you remove it from PATH.
I use the cmd prompt on Windows 10 with psql postgres postgres.
Then I launch pgAdmin4 and it works.
I had this problem with pgadmin4 v2.1 on linux fedora 27
Solved by installing a missing dependency:
python3-flask-babelex
Just click on that pgadmin 4 icon and run as administrator. Allow the access permissions. It will start locally.
I need to add this here because I've had several issues with this message. If you have recently upgraded to High Sierra you will find the latest (pgadmin 4.20) will keep appearing with the message "Application Server Could Not be Contacted". What this actually means on Macs is that python was unable to configure your environment in ~/.pgadmin
This directory stores all the things you setup and configure and even logs of what was ran on your user copy usage of pgadmin.
The way to fix this issue on High Sierra is down to sqlite3. If you look in that directory you'll see everything is stored in sqlite3 files.
When version 4.20 of pgadmin was released it was shipped with a version later than sqlite3.19 and the problem arises because High Sierra is shipped with sqlite3.19, so to fix this issue, you need to replace the old version of sqlite3 with the latest on your packager.
Now be aware, MacosX+ all use sqlite to store details for the majority of apps on your mac, so you'll need to make sure you do not just wipe the old version but you'll have to have both versions co-existing together in harmony to avoid anything major occurring on your mac.
1) download brew https://brew.sh/
2) update brew and upgrade brew to make sure it's up-to-date
3) brew install sqlite3
4) mv /usr/bin/sqlite3 /usr/bin/sqlite3.os
5) ln -s /usr/local/Cellar/sqlite/3.21.0/bin/sqlite3 /usr/bin/sqlite3
6) /usr/bin/sqlite3 -version (check version is later than 3.19)
You can now proceed to open up pgadmin as normal
Got this issue after I upgraded PostgreSQL 9.4 to 9.6. The 9.4 binary package had PgAdmin 3 while 9.6 came with PgAdmin 4. I resolved it after a clean installation (I completely uninstalled and reinstalled) of PostgreSQL.
However, under different circumstances, you could try running the pgAdmin 4 application as an Administrator. This should fix the error.
downloaded pgadmin 4 v2.0 and install it no problem atm on force installation. try it. that was solution for me.
For my case in Windows 10 for postgresql 10 version, it worked by changing SERVER_MODE to False in config_distro.py placed in web folder, as per these configuration settings: https://www.pgadmin.org/docs/pgadmin4/dev/desktop_deployment.html.
There are other settings mentioned in this answer (https://superuser.com/a/1131964) regarding python but I just changed SERVER_MODE and it worked.
Kill it in Windows Task Manager and then try again. It seems that there is some sort of a problem when accessing the server from different applications.
As for me on windows 2012r2 it's start to work only after I reinstall pgAdmin 4 to folder c:\pgAdmin4. With out spaces and any special chars.
And all so I give full permission to this folder in NTFS.
It worked for me after installing python2.7 for pgAdmin 4 v2
Happens mostly when you have multiple versions of pgadmin installed or while trying to upgrade. Even I tried everything from killing the "running PID on port 5432" to "changing the server mode". In my case I uninstall postgres and re-install it again on different port(5433).
Later, I opened it through cmd(right click on cmd and select "run cmd as an Administrator").

How do I install older version of postgresql and postgis?

I am new to Linux and I found it really difficult to install older version of postgresql (along with postgis). I have uninstalled everything I could find connected to postgresql in aptidude. As only the newest version is available through apt-get install, I have went through several tutorials how to get 9.1 installed.
Example: https://wiki.postgresql.org/wiki/Apt (with 9.1 at the end, not 9.3)
After I was done with this tutorial, pgAdmin III is still showing 9.3 as version.
What's the correct way to dump 9.3 and install 9.1 as well as postgis 1.5?
I am using Mint 17
Okay. First off it is perfectly fine to run multiple versions of postgresql alongside one another. You can have more than one cluster on a box, and each cluster can run different versions. The debian pacakges are very well designed to make this easy to do.
However since you've indicated you're a newby to linux/postgresql it's probably best to get 9.3 completely cleaned from your system to avoid frustrating hiccups which will take you a long time to figure out.
To do this you need to:
Purge all postgresql 9.3 packages from dpkg
Manually delete any 9.3 data and configuration for 9.3 cluster
Make sure you've created a 9.1 cluster
Step 1 – purge DPKG
DPKG manages the packages on your system. APT acts as a mechanism for getting packages to install. A lot of DPKG functionality is available through apt, but some things are just easier on dpkg. In your comments you've shown that DPKG is still showing remnants of 9.3. When you uninstall a package some parts of it may hang around (such as configuration files). You can remove multiple packages in one command. To get rid of these completely you can tell dpkg to purge them dpkg --purge <package name>. You can remove multiple packages in one command and it's best to do so.
dpkg --list will list everything on your system. dpkg --list | grep postgresql searches this list for postgresql.
Step 2 – Manually delete data and configuration from the old 9.3 cluster.
When you first install postgresql it creates a cluster for you; no questions asked. This trips up a lot of new users because they neither knew that it happened nor how to replace it. Now that 9.3 is uninstalled you can go ahead and simply delete the configuration and data:
If there was anything you wanted to keep in the installed 9.3 database DO NOT run the following commands
sudo rm -rf /etc/postgresql/9.3 Removes the configuration.
sudo rm -rf /var/lib/postgresql/9.3 Removes the data.
Step 3 – Create a new cluster
You've indicated in comments that postgresql 9.1 is installed. Before you run this command it's worth reading the manual. man pg_createcluster.
sudo pg_createcluster 9.1 <think up a name>
Now you should be able to start up postgresql sudo service postgresql start
Edit
If pg_config is still listing the incorrect version then... this can be a result of remnants of 9.3 still left on your system. This may not be a problem. To allow multiple versions to run along side one another pg_config is a wrapper script which searches for the latest (highest version) of /usr/lib/postgresql/*/bin/pg_config. So what you're seeing is the result of running /usr/lib/postgresql/9.3/bin/pg_config. If 9.3 is completely cleaned from your system then /usr/lib/postgresql/9.3 should have gone.
If you want to see the configuration of 9.1 then try running:
/usr/lib/postgresql/9.1/bin/pg_config.
The wrapper scripts which starts the server will use the file structure of /etc/postgresql and use the apropriate version. So /etc/postgresql/9.1/main will startup version as 9.1.

PostgreSQL different psql and server versions. Can't update or locate psql's destination

I will keep it short for the people who don't want to read too much. Currently, I am trying to run PostgreSQL.app 9.3.0. (Homebrew didn't work and complained that there might be conflicting versions).
It seems to run pretty well, however my psql's version is 9.1.0 and it causes some problems. Psql is probably a left over from another installation/uninstallation maybe a year ago.
Is there a way to update psql or locate it so that I can re-install it. Maybe these two screenshots maybe will give you an idea.
Thank you!
http://i.imgur.com/u3H4hxJ.png
http://i.imgur.com/DaBnzTi.png
Use the 'which' command in the terminal to determine the path/location of the command in question. For example:
$ which psql
/Library/PostgreSQL/9.3/bin/psql
The first image you posted is likely a result of running the psql that comes with default OS X installs. That version is located at:
/usr/bin/psql
I wouldn't recommend removing it however. Instead, once you've installed a version of psql that matches your server (or perhaps it's already there but is just behind the other version in your path), update your path so that the proper psql command comes before the default OS X one and any others. If you are using bash as your preferred shell, for example, then put this in your ~/.bash_profile file:
# add PostgreSQL binaries to the path
export PATH=/Library/PostgreSQL/9.3/bin:$PATH

Installing PDO-drivers for PostgreSQL on Mac (using Zend for eclipse)

How can I get PDO to work on my mac (os x 10.5)? I'm using the built in php and php in Zend/Eclipse. Can't seem to find useful drivers for it at all.
I had to install the PDO_PGSQL driver recently on Leopard, and I ran across a multitude of problems. In my search for answers, I stumbled across this question. Now I have it successfully installed, and so, even though this question is quite old, I hope that what I've found can help others (like myself) who will undoubtedly run into similar problems.
The first thing you'll need to do is install PEAR, if you haven't done so already, since it doesn't come installed on Leopard by default.
Once you do that, use the PECL installer to download the PDO_PGSQL package:
$ pecl download pdo_pgsql
$ tar xzf PDO_PGSQL-1.0.2.tgz
(Note: you may have to run pecl as the superuser, i.e. sudo pecl.)
After that, since the PECL installer can't install the extension directly, you'll need to build and install it yourself:
$ cd PDO_PGSQL-1.0.2
$ phpize
$ ./configure --with-pdo-pgsql=/path/to/your/PostgreSQL/installation
$ make && sudo make install
If all goes well, you should have a file called "pdo_pgsql.so" sitting in a directory that should look something like "/usr/lib/php/extensions/no-debug-non-zts-20060613/" (the PECL installation should have outputted the directory it installed the extension to).
To finalize the installation, you'll need to edit your php.ini file. Find the section labeled "Dynamic Extensions", and underneath the list of (probably commented out) extensions, add this line:
extension=pdo_pgsql.so
Now, assuming this is the first time you've installed PHP extensions, there are two additional steps you need to take in order to get this working. First, in php.ini, find the extension_dir directive (under "Paths and Directories"), and change it to the directory that the pdo_pgsql.so file was installed in. For example, my extension_dir directive looks like:
extension_dir = "/usr/lib/php/extensions/no-debug-non-zts-20060613"
The second step, if you're on a 64-bit Intel Mac, involves making Apache run in 32-bit mode. (If there's a better strategy, I'd like to know, but for now, this is the best I could find.) In order to do this, edit the property list file located at /System/Library/LaunchDaemons/org.apache.httpd.plist. Find these two lines:
<key>ProgramArguments</key>
<array>
Under them, add these three lines:
<string>arch</string>
<string>-arch</string>
<string>i386</string>
Now, just restart Apache, and PDO_PGSQL will be up and running.
Take a look at this PECL package: PDO_PGSQL
I haven't tried it myself, but I've been interested in playing with Postgres as an alternative to MySQL. If I have a chance to try it soon, I'll throw my results up here in case it helps.
I'm not sure this will help with the PDO drivers specifically, but you might look into BitNami's MAPPStack.
I had a ton of trouble with Postgres, PHP, and Apache on my Mac, some of it having to do with 64- vs 32-bit versions of some or all of them. So far, the BitNami MAPPStack install is working nicely in general. Maybe it will help with your PDO issues as well.
Install new php version via brew and restart server, and php -v, all issues are removed.
This is what worked for me
brew install php55-pdo-pgsql
This installs PHP 5.5.32 and PostgreSQL 9.5. I already had PostgreSQL 9.4 installed so I uninstalled the homebrew version with:
brew uninstall postgres
You then have to update /etc/apache2/httpd.conf to point to the correct PHP version and restart Apache:
LoadModule php5_module /usr/local/Cellar/php55/5.5.32/libexec/apache2/libphp5.so
My OSX version is Yosemite.