The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.initdb: invalid locale settings; check LANG and LC_* environment variables
背景
在安装数据库成功之后,使用命令,对数据库进行初始化
service postgresql initdb
报错
Hint: the preferred way to do this is now "/usr/bin/postgresql-setup --initdb --unit postgresql"
* Initializing database in '/var/lib/pgsql/data'
ERROR: Initializing database failed, possibly see /var/lib/pgsql/initdb_postgresql.log
[root@XX]# cat /var/lib/pgsql/initdb_postgresql.log
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.
initdb: invalid locale settings; check LANG and LC_* environment variables
排查原因
原来是没有中文字符集
locale -a|grep zh
解决办法
yum install glibc-common
yum install -y langpacks-zh_CN
source /etc/locale.conf
结果
再次查看
locale -a|grep zh
就有中文字符集了。
重新初始化数据库。
成功
_____
2021-12-10 若上面的方法无法解决增加新的解决办法