UTF8 encoding does not match en_US language; the selected LC_CTYPE setting requires LATIN1 encoding

When trying to install opennms:

/usr/share/opennms/bin/install -l /usr/local/lib -dis 

I get an error message:

ERROR: UTF8 encoding does not match en_US language Details: LATIN1 encoding is required for the selected LC_CTYPE setting.

and I'm not sure how to do this, since I tried to create a database in several different ways (see below).

Full log:

 ============================================================================== OpenNMS Installer ============================================================================== Configures PostgreSQL tables, users, and other miscellaneous settings. - searching for jicmp: - trying to load /usr/local/lib/libjicmp.so: NO - trying to load /usr/lib/jni/libjicmp.so: OK - searching for jicmp6: - trying to load /usr/local/lib/libjicmp6.so: NO - trying to load /usr/lib/jni/libjicmp6.so: OK - searching for jrrd: - trying to load /usr/local/lib/libjrrd.so: NO - trying to load /usr/lib/jni/libjrrd.so: NO - trying to load /usr/lib/jni/libjrrd.so: NO - trying to load /usr/lib/jvm/jdk1.6.0_34/jre/lib/amd64/server/libjrrd.so: NO - trying to load /usr/lib/jvm/jdk1.6.0_34/jre/lib/amd64/libjrrd.so: NO - trying to load /usr/lib/jvm/jdk1.6.0_34/jre/../lib/amd64/libjrrd.so: NO - trying to load /libjrrd.so: NO - trying to load /usr/share/opennms/lib/libjrrd.so: NO - trying to load /usr/share/opennms/lib/linux64/libjrrd.so: NO - trying to load /usr/java/packages/lib/amd64/libjrrd.so: NO - trying to load /usr/lib64/libjrrd.so: NO - trying to load /lib64/libjrrd.so: NO - trying to load /lib/libjrrd.so: NO - trying to load /usr/lib/libjrrd.so: NO - trying to load /usr/lib/jni/libjrrd.so: NO - trying to load /usr/lib/libjrrd.so: NO - trying to load /usr/local/lib/libjrrd.so: NO - trying to load /opt/NMSjicmp/lib/32/libjrrd.so: NO - trying to load /opt/NMSjicmp/lib/64/libjrrd.so: NO - trying to load /opt/NMSjicmp6/lib/32/libjrrd.so: NO - trying to load /opt/NMSjicmp6/lib/64/libjrrd.so: NO - Failed to load the optional jrrd library. - This error is not fatal, since jrrd is only required for optional features. - For more information, see http://www.opennms.org/index.php/jrrd - using SQL directory... /usr/share/opennms/etc - using create.sql... /usr/share/opennms/etc/create.sql * using 'postgres' as the PostgreSQL user for OpenNMS * using 'opennms' as the PostgreSQL database name for OpenNMS Exception in thread "main" org.opennms.core.schema.MigrationException: an error occurred creating the OpenNMS database at org.opennms.core.schema.Migrator.createDatabase(Migrator.java:428) at org.opennms.core.schema.Migrator.prepareDatabase(Migrator.java:444) at org.opennms.install.Installer.install(Installer.java:236) at org.opennms.install.Installer.main(Installer.java:949) Caused by: org.postgresql.util.PSQLException: ERROR: encoding UTF8 does not match locale en_US Detail: The chosen LC_CTYPE setting requires encoding LATIN1. at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2102) at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1835) at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257) at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:500) at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:374) at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:366) at org.opennms.core.schema.Migrator.createDatabase(Migrator.java:425) ... 3 more 

List of Databases:

  Name | Owner | Encoding | Collate | Ctype | Access privileges -----------+----------+----------+---------+-------+----------------------- postgres | postgres | LATIN1 | en_US | en_US | rhq | rhqadmin | LATIN1 | en_US | en_US | template0 | postgres | LATIN1 | en_US | en_US | =c/postgres + | | | | | postgres=CTc/postgres template1 | postgres | LATIN1 | en_US | en_US | =c/postgres + | | | | | postgres=CTc/postgres (4 rows) 

I used the following 3 initdb options, but none of them work

 /usr/local/pgsql/bin/initdb -E UTF-8 --pgdata=/usr/local/pgsql/data /usr/local/pgsql/bin/initdb -E LATIN1 --pgdata=/usr/local/pgsql/data /usr/local/pgsql/bin/initdb -E en_US.UTF8 --pgdata=/usr/local/pgsql/data 

Also, do I need to delete all data in /usr/local/pgsql/data before using initdb ?

adding the locale stdout command:

$ locale

 LANG=en_US LANGUAGE=en_US: LC_CTYPE="en_US" LC_NUMERIC="en_US" LC_TIME="en_US" LC_COLLATE="en_US" LC_MONETARY="en_US" LC_MESSAGES="en_US" LC_PAPER="en_US" LC_NAME="en_US" LC_ADDRESS="en_US" LC_TELEPHONE="en_US" LC_MEASUREMENT="en_US" LC_IDENTIFICATION="en_US" LC_ALL= 
+44
encoding postgresql opennms
Oct 29
source share
7 answers

Thanks for the output of locale . Apparently, OpenNMS uses the en_US (non-UTF-8) locale 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 
+12
Oct 29 '12 at 4:45
source share

I answer this because none of StackOverFlow worked for me.

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

Create 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

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

Reconfigure so that the encoding can be UTF8 ([obtained 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 pattern1 to create db.

I hope this helps;)

+97
Jul 10 '13 at 7:53 on
source share

This is because your system is configured 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 install all of your applications that are installed after the change (I think) to use Unicode-encoded English. Further information can be found here: https://www.linux.com/learn/docs/ldp/790-Unicode-HOWTO#s3

I had a similar problem, so I:

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

and then postregsql knew that it should use Unicode-encoded English.

Of course, you can do this for each database, as described here: http://www.postgresql.org/docs/9.1/static/multibyte.html

+5
Apr 24 '14 at 15:53
source share

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; 
+4
Apr 7 '14 at 22:44
source share

Change locales and SO languages ​​for compatibility with BD.

dpkg-reconfigure locales

enjoy it!

+1
04 Oct '13 at 18:17
source share

I meet a similar error. the old LC_CTYPE database is UTF-8, but the new one is en_US.UTF-8, I am solving the problem after restoring the database.

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

You must select the correct option -E

0
Mar 23 '17 at 6:51
source share

I had the "same problem" when installing odoo. It turns out that before installing odoo you need to configure the locale

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

And then the configurator localizer with UTF-8, BUT you must configure the locale before installing posgres.

0
Dec 20 '18 at 12:04 on
source share



All Articles