1

Upgraded from 9.1 to 9.3 on my Ubuntu 12.04 server. Everything worked great but running commands like 'createdb' still runs them from the 9.1 path.

/usr/lib/postgresql/9.1/bin/createdb: unrecognized option....

Edit, additional info: I used this gist https://gist.github.com/ibussieres/11262268 I already uninstalled 9.1 with the regular 'sudo apt-get remove postgresql-9.1'

This is the output of requested commands

which createdb
  /usr/bin/createdb

createdb --version
  createdb (PostgreSQL) 9.1.14

which psql
  /usr/bin/psql

psql --version
  psql (PostgreSQL) 9.3.5
4

Option 1: remove createdb for 9.1

When in doubt, use dpkg -S to learn which packages provide a certain command.

Example:

$ dpkg -S createdb 
postgresql-doc-9.1: /usr/share/doc/postgresql-doc-9.1/html/tutorial-createdb.html 
postgresql-doc-9.1: /usr/share/doc/postgresql-doc-9.1/html/app-createdb.html 
postgresql-client-9.1: /usr/lib/postgresql/9.1/bin/createdb
postgresql-client-common: /usr/bin/createdb 
postgresql-doc-9.1: /usr/share/doc/postgresql-doc-9.1/html/manage-ag-createdb.html 
postgresql-client-9.1: /usr/share/postgresql/9.1/man/man1/createdb.1.gz 
wwwconfig-common: /usr/share/wwwconfig-common/pgsql-createdb.sh 

From this it appears that /usr/lib/postgresql/9.1/bin/createdb is provided by postgresql-client-9.1, and that it's still installed. You may uninstall it since presumably you have now postgresql-client-9.3

Option 2: address the right instance without removing anything

Debian allows multiple simultaneous PostgreSQL instances, which is why it allows to have different createdb at the same time. Assuming you'd need to keep postgresql-client-9.1, that is possible too.

The /usr/bin/createdb command, in the standard $PATH (as opposed to deep under /usr/lib), is actually a wrapper that will call the real binary for the correct version depending on the context.

That context may be given through the additional option, specific to Debian/Ubuntu, called --cluster to specify which version and server it should target. It's also available as an environment variable PGCLUSTER, as documented in pg_wrapper, and defaults can also be specified in /etc/postgresql-common/user_clusters.

Weird: createdb pointing to 9.1.14 and psql to 9.3.5

The one thing that doesn't look right in your question is this issue. Normally pgsql and createdb should reach the same version/cluster, since in fact they should point to the same script to start with:

$ ls -l /usr/bin/createdb /usr/bin/psql
lrwxrwxrwx 1 root root 37 sept.  8  2012 /usr/bin/createdb -> ../share/postgresql-common/pg_wrapper
lrwxrwxrwx 1 root root 37 sept.  8  2012 /usr/bin/psql -> ../share/postgresql-common/pg_wrapper

This would require further digging into the environment to find out how your situation differs from the default.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.