问题
(一)系统汉化后数据库连接失败
psql: 错误: 连接到套接字”/var/run/postgresql/.s.PGSQL.5432”上的服务器失败:没有那个文件或目录
查看/var/log/postgresql
下的日志
2022-05-16 09:03:26.653 HKT [2740] LOG: invalid value for parameter “lc_messages”: “en_US.UTF-8”
2022-05-16 09:03:26.653 HKT [2740] LOG: invalid value for parameter “lc_monetary”: “en_US.UTF-8”
2022-05-16 09:03:26.653 HKT [2740] LOG: invalid value for parameter “lc_numeric”: “en_US.UTF-8”
2022-05-16 09:03:26.653 HKT [2740] LOG: invalid value for parameter “lc_time”: “en_US.UTF-8”
2022-05-16 09:03:26.653 HKT [2740] FATAL: configuration file “/etc/postgresql/14/main/postgresql.conf” contains errors
pg_ctl: could not start server
Examine the log output.
原因是汉化后去掉了en_US.UTF-8 编码
sudo dpkg-reconfigure locales
将en_US.UTF-8 编码添加回来即可
(二)切换语言环境后连接数据库失败
查看/var/log/postgresql
下的日志,发现
psql: 错误: 连接到套接字”/var/run/postgresql/.s.PGSQL.5432”上的服务器失败:FATAL: database locale is incompatible with operating system
描述: The database was initialized with LC_COLLATE “en_HK.UTF-8”, which is not recognized by setlocale().
提示: Recreate the database with another locale or install the missing locale.
原因是编码不同
sudo localedef -f UTF-8 -i en_US en_US.UTF-8
参考文章
connect to postgresql database with different locale
转载请注明来源,欢迎对文章中的引用来源进行考证,文章可能具有时效性,欢迎指出任何有错误、已失效或不够清晰的表达 ,可通过[邮件](mailto:cnlnnn@qq.com)联系垃圾堆主人