PostgreSQL setup issue on macOS Monterey: initdb error encoding mismatch
0
votes
1
answer
45
views
I'm having issue while installing PostgreSQL 16 on macOS Monterey via MacPorts.
So far, these looked OK:
$ sudo port install postgresql16-server
---> Computing dependencies for postgresql16-server
The following dependencies will be installed: postgresql16
Continue? [Y/n]: y
---> Fetching archive for postgresql16
Warning: Your DNS servers incorrectly claim to know the address of nonexistent hosts. This may cause checksum mismatches for some ports. See this page for more information:
...
...
...
---> No broken files found.
---> No broken ports found.
---> Some of the ports you installed have notes:
postgresql16 has the following notes:
To use the postgresql server as a startup item install the postgresql16-server port.
postgresql16-server has the following notes:
To create a database instance, after install do
sudo port select postgresql postgresql16
sudo mkdir -p /opt/local/var/db/postgresql16/defaultdb
sudo chown postgres:postgres /opt/local/var/db/postgresql16/defaultdb
sudo -u postgres /bin/sh -c 'cd /opt/local/var/db/postgresql16 && /opt/local/lib/postgresql16/bin/initdb -D /opt/local/var/db/postgresql16/defaultdb'
Except at the last part:
$ sudo -u postgres /bin/sh -c 'cd /opt/local/var/db/postgresql16 && /opt/local/lib/postgresql16/bin/initdb -D /opt/local/var/db/postgresql16/defaultdb'
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.
The database cluster will be initialized with this locale configuration:
provider: libc
LC_COLLATE: cs_CZ.ISO8859-2
LC_CTYPE: en_US.UTF-8
LC_MESSAGES: en_US.UTF-8
LC_MONETARY: en_US.UTF-8
LC_NUMERIC: en_US.UTF-8
LC_TIME: en_US.UTF-8
The default database encoding has accordingly been set to "UTF8".
initdb: error: encoding mismatch
initdb: detail: The encoding you selected (UTF8) and the encoding that the selected locale uses (LATIN2) do not match. This would lead to misbehavior in various character string processing functions.
initdb: hint: Rerun initdb and either do not specify an encoding explicitly, or choose a matching combination.
I have no idea how to fix this. Running
sudo -u postgres /bin/sh -c 'cd /opt/local/var/db/postgresql16 && /opt/local/lib/postgresql16/bin/initdb -D /opt/local/var/db/postgresql16/defaultdb -E UTF8'
gives same eror message.
Perhaps this can provide some hints:
$ locale
LANG="en_US.UTF-8"
LC_COLLATE="cs_CZ.ISO8859-2"
LC_CTYPE="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_ALL=
Asked by anta40
(103 rep)
Sep 20, 2024, 05:49 PM
Last activity: Sep 23, 2024, 12:47 PM
Last activity: Sep 23, 2024, 12:47 PM