在 Ubuntu 12.04 上安装 Postgresql 9.2

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17399622/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 00:15:12  来源:igfitidea点击:

Postgresql 9.2 installation on Ubuntu 12.04

postgresqlubuntuubuntu-12.04postgresql-9.2

提问by Naresh J

For installing postgresql 9.2I followed this url : http://www.ubuntugeek.com/how-to-install-postgresql-9-2-on-ubuntu-server-using-ppa.html

为了安装postgresql 9.2我遵循了这个网址:http: //www.ubuntugeek.com/how-to-install-postgresql-9-2-on-ubuntu-server-using-ppa.html

But at the end of installation output is like :

但在安装结束时,输出类似于:

Setting up postgresql-common (140~precise) ...
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
Adding user postgres to group ssl-cert
Building PostgreSQL dictionaries from installed myspell/hunspell packages...
 * No PostgreSQL clusters exist; see "man pg_createcluster"
Setting up postgresql-9.2 (9.2.4-0ppa1~precise) ...
Error: The locale requested by the environment is invalid.
Error: could not create default cluster. Please create it manually with

  pg_createcluster 9.2 main --start

or a similar command (see 'man pg_createcluster').
update-alternatives: using /usr/share/postgresql/9.2/man/man1/postmaster.1.gz to provide /usr/share/man/man1/postmaster.1.gz (postmaster.1.gz) in auto mode.
 * No PostgreSQL clusters exist; see "man pg_createcluster"
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place

And when I tried to start postgresql, it gives following error :

当我尝试启动 postgresql 时,它出现以下错误:

sudo /etc/init.d/postgresql start
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = (unset),
    LC_MESSAGES = "en_IN.UTF-8",
    LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
 * No PostgreSQL clusters exist; see "man pg_createcluster"

How can I fix this problem ?

我该如何解决这个问题?

回答by Dave Flynn

I tried all of the solutions that I could find, but in the end this post sorted it:

我尝试了我能找到的所有解决方案,但最后这篇文章对其进行了排序:

http://ubuntuforums.org/showthread.php?t=1720356

http://ubuntuforums.org/showthread.php?t=1720356

Basically, add the language you want to /etc/environment. In my case:

基本上,将您想要的语言添加到 /etc/environment。就我而言:

sudo nano /etc/environment

Then added this to the end of the file:

然后将其添加到文件末尾:

LC_ALL="en_US.utf-8"

Then reboot the server

然后重启服务器

sudo reboot

回答by Craig Ringer

Your system locale configuration is messed up. Your LC_MESSAGESis set to en_IN.UTF-8but LANGis set to en_US.UTF-8which is weird and inconsistent. Did you set LC_MESSAGESin your ~/.bash_profile, /etc/environmentor something?

您的系统语言环境配置搞砸了。您LC_MESSAGES设置为en_IN.UTF-8LANG设置en_US.UTF-8为奇怪且不一致。你设置LC_MESSAGES了你的~/.bash_profile/etc/environment还是什么?

You really should dpkg-reconfigure locales. See how to select and generate locales in Ubuntu.

你真的应该dpkg-reconfigure locales。了解如何在 Ubuntu 中选择和生成语言环境

Once you've fixed your locale setup, you can use the pg_wrappercommand pg_createcluster 9.2 main --startas suggested by the error to create the cluster. After that, starting the service will work.

修复区域设置后,您可以使用错误建议的pg_wrapper命令pg_createcluster 9.2 main --start来创建集群。之后,启动服务将起作用。