Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

When I connect to a Postgresql DB using psql, I often get these messages:

=> SELECT * FROM question_view ;
ERROR:  character with byte sequence 0xd7 0x9e in encoding "UTF8" has no equivalent in encoding "LATIN1"

Following this SO answer, I understand that I should change the client encoding accordingly:

SET client_encoding = 'UTF8';

Changing the client_encoding every time I connect to the DB is cumbersome. Is there a way to permanently configure this setting, either in the .pgpass file or anywhere else?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

Is there a way to permanently configure this setting, either in the .pgpass file or anywhere else

Yes there is: it's ~/.psqlrc (or %APPDATA%\postgresql\psqlrc.conf in Windows)

See the manual for details: http://www.postgresql.org/docs/current/static/app-psql.html#AEN88713

share|improve this answer
    
Adding SET client_encoding = 'UTF8'; to ~/.psqlrc did the trick. Thanks! –  Adam Matan Jul 15 '14 at 21:21
    
This doesn't seem to work when (re)connecting from within a psql session, for example after restarting the server. –  Adam Mackler Aug 20 '14 at 18:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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