encoding UTF8 does not match locale en_US; the chosen LC_CTYPE setting requires encoding LATIN1

情到浓时终转凉″ 提交于 2019-11-29 19:51:49

Thanks for locale output. OpenNMS seems to be using your en_US (non-UTF-8) locale in order to create postgres db, and this is wrong. This should work:

export LANG=en_US.UTF-8
locale   # confirm that it shows only en_US.UTF-8 for all settings
# finally, run your opennms installer
/usr/share/opennms/bin/install -l /usr/local/lib -dis
Avia

I am answering this because nothing from StackOverFlow worked for me.

I combined two solutions from other sites that did the job (this answer works for Ubuntu server 12.04 and PGSQL 9.1):

Create a file:

nano /etc/profile.d/lang.sh

Add the following

export LANGUAGE="en_US.UTF-8"
export LANG="en_US.UTF-8"
export LC_ALL="en_US.UTF-8"

Save it

Restart shell or run all export commands manually in current shell instance

Reconfigure so the encoding can be UTF8 ([got it from here][1])

sudo su postgres

psql

update pg_database set datistemplate=false where datname='template1';
drop database Template1;
create database template1 with owner=postgres encoding='UTF-8'

  lc_collate='en_US.utf8' lc_ctype='en_US.utf8' template template0;

update pg_database set datistemplate=true where datname='template1';

Use template1 for db creation.

I hope this helps ;)

This is happening because your system is setup to use Latin1 encoding instead of UTF-8. Your language is set correctly to en_US, but the encoding is not set to UTF-8. Try running this:$

localedef -v -c -i en_US -f UTF-8 en_US.UTF-8

This will set tell all of your applications that are installed after the change (i think) to use the English language with unicode encoding. More information can be found here: https://www.linux.com/learn/docs/ldp/790-Unicode-HOWTO#s3

I had a similar issue so I:

  1. aptitude purge postresql ...
  2. localedef -v -c -i en_US -f UTF-8 en_US.UTF-8
  3. aptitude install postresql ....

and then postregsql knew to set itself to use the english language with unicode encoding.

Of course, you could do this on a per database basis as described here: http://www.postgresql.org/docs/9.1/static/multibyte.html

this worked for me:

CREATE DATABASE mydb WITH ENCODING='UTF8' LC_CTYPE='en_US.UTF-8' LC_COLLATE='en_US.UTF-8' OWNER=postgres TEMPLATE=template0 CONNECTION LIMIT=-1;

Change the locales and languages of SO for compatibilty with BD.

dpkg-reconfigure locales

enjoy!

jadeydi

I meet the similar error. old database LC_CTYPE is UTF-8, but new one is en_US.UTF-8, I solve the problem after reinit database.

initdb --pgdata=/path/to/postgresql -E utf8

You should choice the right -E parameter

I have had the "same issue" while installing odoo. Turns out that before installing odoo you have to configure locale

export LC_CTYPE="en_US.UTF-8"
sudo dpkg-reconfigure locales

And then configuler locale with UTF-8 BUT you have to configure locale before posgres installation.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!