Full Error
FATAL: database locale is incompatible with operating system
Detail: The database was initialized with LC_COLLATE "th_TH.UTF-8", which is not recognized by setlocale()
Solution
- Linux Server Ubuntu Base
Sol#01
- Check current locale
locale -a
- If not found th_TH.UTF-8, run these command to install Thai locale
sudo locale-gen en_US en_US.UTF-8 th_TH th_TH.UTF-8 sudo dpkg-reconfigure locales
- recheck result with
locale -a
C C.utf8 en_US.utf8 POSIX th_TH.utf8 << new locale
Sol#02 or you can edit /etc/locale.gen with text editor such as nano and uncomment (Remove #)
in line th_TH.UTF-8
#Remove # from th_TH.UTF-8 nano -w /etc/locale.gen en_US.UTF-8 #th_TH.UTF-8 >> OLD th_TH.UTF-8
- Regen Locale
locale-gen
- check result with locale -a
#result of locale -a C C.utf8 en_US.utf8 POSIX th_TH.utf8 << new locale
Note: you can use replace command like sed to replace value, the example I will show in Container case
- For Container Base
Default thai local in dockerfile
FROM postgres:16.0 RUN apt-get update RUN apt-get install -y locales RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \ locale-gen #you logic such as inital script # ...
Reference
Discover more from naiwaen@DebuggingSoft
Subscribe to get the latest posts sent to your email.