PostgreSQL initdb报错:先是:initdb: invalid locale name "zh_CN.UTF-8" 然后是: initdb: invalid locale settings; check LANG and LC_* environment variables
在安装PostgreSQL时, initdb报错:
先是:initdb: invalid locale name "zh_CN.UTF-8"
然后是: initdb: invalid locale settings; check LANG and LC_* environment variables
背景:
服务器系统为CentOS8,目前客户环境中只有en_US.UTF-8字符集。
问题记录:
一、报错:initdb: invalid locale name "zh_CN.UTF-8"
1)原因是在initdb时指定了编码为字符集为zn_CN.UTF-8,而系统没有这个编码导致的。
2)修改为:
initdb xxxx -E UTF-8
不指定具体的编码集,默认就使用了本地的en_US.UTF-8编码,初始化成功。
二、报错:initdb: invalid locale settings; check LANG and LC_* environment variables
但是客户要求用zh_CN.UTF-8编码,就需要重新初始化:
1)修改系统编码:
vim /etc/locale.conf
LANG=zh_CN.utf8
source /etc/locale.conf
2)查看系统编码:
env
LANG改过来了
3)再次初始化,此时报错:
initdb: invalid locale settings; check LANG and LC_* environment variables
4)查看系统是包含zh_CN.UTF-8字符集:
locale -a|grep zh
--发现没有
locale
除了LANG是zh_CN.UTF-8,其他都是en_US.UTF-8
5)安装中文字符集
yum install glibc-common
yum install -y langpacks-zh_CN
source /etc/locale.conf
locale -a|grep zh
--有中文字符集了
6)查看字符集
locale
都是中文的了
7)重新初始数据库目录,成功,数据库编码为zh_CN.UTF-8
三、en_US.UTF-8 和 zh_CN.UTF-8 字符集区别:
en_US.UTF-8 和 zh_CN.UTF-8 包含的字符数量是基本上一样的,大概是七万个汉字,编码都是 UTF-8 编码,字符集是 Unicode,版本是 4.1 吧?zh_CN.GB18030 和 zh_CN.GBK 的字符集都与 Unicode 3 是等价的,记得应该是这样
语言环境的差别就是另一回事了,中国人和外国人表示时间啦,数字啦,习惯都不一样,所以必须区分开。大部分程序根据语言环境变量来选择界面的语言是中文还是英文。
所以一般linux系统的语言环境设置成:export LANG=zh_CN.UTF-8,代表中国人使用的unicode字符集
相关文章
- 解决MyBatis报错 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
- mysql报错ERROR 1356 (HY000): View ‘mysql.user‘ references invalid table(s) or column(s) or function(s)
- Angular启动/node_modules/@types/node/index.d.ts (20,1): Invalid ‘reference‘ directive syntax.
- 解决Invalid bound statement (not found)(Mybatis的Mapper绑定问题)
- springBoot报错:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
- Xcode8 - apploader 上传失败 - ERROR ITMS-90168: "The binary you uploaded was invalid."
- org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.ycgwl.rosefinch.module.basedev.server.dao.base.IBaseCustomerDao.updateCustomerEntity
- PhpStorm和PHPstudy配置调试参数(Xdebug),问题描述Error. Interpreter is not specified or invalid. Press “Fix” to edit your project configuration.
- Fatal error compiling: invalid target release: 11 -> [Help 1]
- [WARNING] The POM for com.tenyears:base-common:jar:1.0 is invalid, transitive dependen
- [WARNING] The POM for com.tenyears:base-common:jar:1.0 is invalid, transitive dependen
- 301. Remove Invalid Parentheses