I'm currently running a OS X Lion Server system which ships with a built-in and not-upgradable PostgreSQL version. After years of usage I've finnaly decided to leave the built-in version and install an indipendent version. I disabled the built-in installation and downloaded the installer from EDB and followed the wizard. After many issues reguarding encoding and locales, I've finally managed how to setup a DB with no locale and UTF8 encoding. I issued the following command:
initdb -D /path/to/data --no-locale --encoding=UTF8
If I connect using pgAdminIII I get no problems. The command show client_encoding;
displays UNICODE
as the encoding used by pgAdminIII (the default installation gave me a SQL_ASCII
encoding and that's why I run the initdb
command).
The problem is that I'm not able to connect to PostgreSQL using psql
. Whatever I pass to it, I get the following error:
psql: invalid connection option "client_encoding"
I've searched through the Internet but found nothing that solves my problem (for example issuing env PGCLIENTENCODING=UTF8
and adding client_encoding=UTF8
to postgresql.conf
).
otool -L /Library/PostgreSQL/9.4/bin/psql
returns:
/Library/PostgreSQL/9.4/bin/psql:
@loader_path/../lib/libpq.5.dylib (compatibility version 5.0.0, current version 5.7.0)
@loader_path/../lib/libssl.1.0.0.dylib (compatibility version 1.0.0, current version 1.0.0)
@loader_path/../lib/libedit.0.dylib (compatibility version 1.0.0, current version 1.48.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)
Anyone can help me to figure it out?
Many thanks to all Pietro
UPDATE
I forgot to logout and then login after editing the bash profile. The suggestion made by Daniel Vérité was right. I just edited the DYLD_LIBRARY_PATH
env variable in /etc/profile
in order to make it visible at a global level and not only from the interactive shell.
I added the following line to /etc/profile
:
export DYLD_LIBRARY_PATH='/Library/PostgreSQL/9.4/lib'
I hope this helps others.
Daniel, Thank you a lot
psql
instead of the new one. Invoke commands with their full paths to be sure. – Daniel Vérité Nov 6 '15 at 13:55LD_LIBRARY_PATH
. Not sure about MacOS. – Daniel Vérité Nov 6 '15 at 14:17otool -L /path/to/psql
would be able to tell. – Daniel Vérité Nov 6 '15 at 14:38libpq
. As this option was added in 2011, it makes sense if you're using a newer psql with an older libpq. SettingDYLD_LIBRARY_PATH
to/Library/PostgreSQL/9.4/lib
could work, or if not google around for other tweaks to the same effect. – Daniel Vérité Nov 6 '15 at 16:20