Change language of system and error messages in PostgreSQL

前端 未结 4 451
心在旅途
心在旅途 2020-12-13 18:09

Is it possible to change the language of system messages from PostgreSQL?

In MSSQL for instance this is possible with the SQL statement SET LANGUAGE.

4条回答
  •  长情又很酷
    2020-12-13 18:52

    Milen's answer didn't work for me.

    I got it working by modifying a file postgresql.conf. If you're on Linux, write:

    sudo find / -iname postgresql.conf
    

    I had mine in /var/lib/pgsql/data. Then edit the file and search for a variable lc_messages and change it to your preferred language, e.g. 'en_US.UTF-8'.

    If PostgreSQL stops working and you check in its log that you have an error that looks like this:

    invalid value for parameter "lc_messages": "en_US.UTF-8"
    

    You have to edit /etc/locale.gen and uncomment line with encoding from the error message (e.g. en_US.UTF-8). Then you have to run locale-gen (as root) to update the locales. Finally, to check if the locale is set you can run locale -a.

    Or, if you want the language to be English, you can just set lc_messages = 'C'.

提交回复
热议问题