Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PostgreSQL 10 on Linux - LC_COLLATE locale en_US.utf-8 not valid

Tags:

postgresql

ERROR: invalid locale name: "en_US.utf-8"

Running Ubuntu server 18.04 Beta 2 with PostgreSQL 10.

In running a database creation script that worked on 9.5, I am now seeing an issue with 'en_US.UTF-8' as a locale:

CREATE DATABASE db WITH TEMPLATE = template0 ENCODING = 'UTF8' LC_COLLATE = 'en_US.UTF-8' LC_CTYPE = 'en_US.UTF-8';

I know this may be redundant as I understand the default to be 'en_US.etf-8'. Removing the LC_COLLATE and LC_CTYPE parameters let me run my script.

So did the locale definitions change somehow for V 10? Or is there something else now happening? I couldn't find anything on this in the Postgres 10 manual.

like image 391
Nathan Smith Avatar asked Apr 11 '18 19:04

Nathan Smith


People also ask

What is locale in postgres?

Locale support refers to an application respecting cultural preferences regarding alphabets, sorting, number formatting, etc. PostgreSQL uses the standard ISO C and POSIX locale facilities provided by the server operating system. For additional information refer to the documentation of your system.

Does Postgres support list?

Lists of text, numbers and more. PostgreSQL gives the opportunity to define a column of a table as a variable length single or multidimensional array. Arrays of any built-in or user-defined base type, enum type, or composite type can be created.


2 Answers

check for available locales with locale -a if not found, try manually adding it with:

locale-gen en_US.UTF-8 

after this

CREATE DATABASE db WITH TEMPLATE = template0 ENCODING = 'UTF8' LC_COLLATE = 'en_US.UTF-8' LC_CTYPE = 'en_US.UTF-8';

should work

like image 167
Vao Tsun Avatar answered Oct 10 '22 20:10

Vao Tsun


I had the same error, I generated the new locale:

locale-gen en_US.UTF-8 

I verified with locale -a that it was in fact present, then I logged out just to make sure, but I was still getting the same error on the database creation.

Finally, I solved the error by simply restarting the postgresql server with:

sudo systemctl restart postgresql

After that, the database creation command was working!

like image 42
William Avatar answered Oct 10 '22 21:10

William