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

前端 未结 4 1051
借酒劲吻你
借酒劲吻你 2021-01-05 06:55

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

Running Ubuntu server 18.04 Beta 2 with PostgreSQL 10.

In running a database creatio

相关标签:
4条回答
  • 2021-01-05 07:24

    Got the same error in a docker container. Here is how I solved it non interactively.

    RUN echo "en_US UTF-8 " >> /etc/locale.gen && locale-gen
    
    0 讨论(0)
  • 2021-01-05 07:26

    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!

    0 讨论(0)
  • 2021-01-05 07:33

    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

    0 讨论(0)
  • 2021-01-05 07:35

    It's been performed on kubuntu and works perfectly, with some additional steps previously mentioned above, the right steps should be:

    1. Validate the existence; if it doesn't exist, proceed to create it (will require sudo privileges)

      locale -a  |grep -i 'es_ES.utf-8'
      sudo locale-gen es_PE.UTF-8
      
    2. Validate if the locale was created.

      locale -a|grep -i es
      es_ES.utf8
      es_PE.utf8
      
    3. After the creation of the locale proceed to restart the postgres service, otherwise u will be getting the following error :

      ERROR:  invalid locale name: "es_ES.UTF-8"
      
    4. Restart the postgres service

      systemctl restart postgresql
      
    5. Finally, database was created.

      postgres=# create database db_izipay_prod with template=template0 encoding='utf8' lc_collate='es_ES.UTF-8' lc_ctype='es_ES.UTF-8' owner=postgres;
      CREATE DATABASE
      
    0 讨论(0)
提交回复
热议问题