PostgreSQL 9.1安装和数据库编码 [英] PostgreSQL 9.1 installation and database encoding

查看:80
本文介绍了PostgreSQL 9.1安装和数据库编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚在Ubuntu 10.04上首次安装了PostgreSQL 9.1。



注意:我已经在Windows上使用安装程序完成了几次,没有问题。

p>

经过一番努力,我将其设置为通过pgAdminIII进行远程连接。但是,连接到数据库后,我真的很惊讶,我收到了有关编码的警告。 postgres数据库本身是使用 SQL_ASCII编码创建的。每次我在Windows上安装时,它都会使用 UTF8创建postgres DB-看起来会好很多,并且在通过pgAdminIII打开数据库时会停止警告消息。



我做错了什么吗?是否有安装选项/参数可用于设置要使用的默认编码?



还有反正可以解决此问题吗?我在网络上阅读了一些内容,指出您需要哑巴并还原才能更改数据库的编码,但是我不确定在postgres db上是否有可能。是吗?



感谢您的帮助!

解决方案

欧文·布兰德斯特(Erwin Brandstetter)提供的答案很有帮助,但是由于某种原因,它对我没有用。原因是我无法运行initdb。尝试使用语言环境运行它时,我一直收到 bash:找不到命令错误。我最终要做的是:



更改操作系统的语言环境。对我来说,这是:

  $ update-locale LANG = en_US.UTF-8 

注意:然后我必须重新启动服务器。要确认它是否有效,只需运行:

  $语言环境

设置好该设置后,我停止并删除了群集:

  $ su postgres 
$ pg_dropcluster --stop 9.1 main

注意:main是默认集群为我创建了(您的群集名称可能有所不同)

  $ pg_createcluster --start 9.1 main 

同样,我只是重新创建了一个具有相同名称(主名称)的集群。



<注意:因为我选择了相同的集群名称(主集群),所以我不得不返回并更新.conf文件。对我来说,这特别是postgres.conf和pg_hba.conf来重新启用对盒子的远程访问。我不会在这里介绍如何执行此操作,因为网络上有很多为此目的的文档。但是,如果有人想稍后编辑此答案以包含它,那就太好了! :)


I just did my first install of PostgreSQL 9.1 on Ubuntu 10.04.

note: I have done it a few times on Windows with an installer without issues.

After a bit of effort, I got it set up to connect remotely via pgAdminIII. However, I was really surprised after connecting to the db, that I got a warning about the encoding. The "postgres" database itself was created with "SQL_ASCII" encoding. Every time that I've installed on windows, it created the postgres DB with "UTF8" - which seems like it would be a lot better and would stop the warning message when opening up the database via pgAdminIII.

Is there something I did wrong? Is there an installation option/param to use to set the default encoding to use?

And is there anyway to fix this? I've read some things on the web that says that you need to dumb and restore to change the encoding of a database, but I'm not sure this is even possible on the postgres db. Is it?

Thanks for your help!

解决方案

The answer provided by Erwin Brandstetter, was helpful, but for whatever reason, it didn't work for me. The reason is that I couldn't initdb to ever run. I kept getting a "bash: command not found" error when trying to run it with the locale. What I ended up doing was:

changing the locale of the OS. For me, this was:

$ update-locale LANG=en_US.UTF-8

Note: then I had to reboot the server. To confirm that it worked, just run:

$ locale

with that set, I stopped and dropped the cluster:

$ su postgres
$ pg_dropcluster --stop 9.1 main

note: main is the default cluster that got created for me (your cluster name might be different)

$ pg_createcluster --start 9.1 main

Again, I just recreated the cluster with the same name (main).

Note: because I picked the same cluster name (main), I had to go back and update my .conf files. For me, this specifically was postgres.conf and pg_hba.conf to re-enable remote access to the box. I'm not going to include how to do that here as there is lots of documentation on the web for this. But, if someone wants to edit this answer later to include it, that would be fine! :)

这篇关于PostgreSQL 9.1安装和数据库编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆