PostgreSQL 数据库安装与配置

在本章节,你将看到如何配置PostgreSQL用于OpenERP。以下流程在PostgreSQLv9.0上很好地测试过。

PostgreSQL 数据库安装

你可以从这里下载Windows 安装包 PostgreSQL download page

依照你的需要,选择One Click安装包,或选择pgInstaller,然后运行你刚下载的可执行文件。

配置PostgreSQL角色用户

当所需的软件安装完成,你必须设置一个PostgreSQL用户。OpenERP将使用这个用户连接到PostgreSQL。

新增用户

启动Windows控制台(在开始菜单的搜索程序和文件文本框运行 ‘’cmd’’ 命令)。

变更目录到 PostgreSQL bin 目录 (例如 C:\Program Files\PostgreSQL\9.0\bin) 或者将这个目录添加到你的 PATH 环境变量。

PostgreSQL的默认超级用户叫 postgres。密码是你在安装过程中设置的。

在你的 Windows 控制台,输入:

  C:\Program Files\PostgreSQL\9.0\bin>createuser.exe --createdb --username postgres --no-createrole --pwprompt openpg
  Enter password for new role: openpgpwd
  Enter it again: openpgpwd
  Shall the new role be a superuser? (y/n) y
  Password: XXXXXXXXXX

* line 1 is the command itself
* line 2 asks you the new user's password
* line 3 asks you to confirm the new user's password
* line 4 new role is superuser or not?
* line 5 asks you the *postgres* user's password

选项解释:

  • --createdb : the new user will be able to create new databases
  • --username postgres : createuser will use the postgres user (superuser)
  • --no-createrole : the new user will not be able to create new users
  • --pwprompt : createuser will ask you the new user’s password
  • openpg : the new user’s name. Alternatively, you may specify a different username.
  • openpgpwd : the new user’s password. Alternatively, you may specify a different password.

Note

密码

在OpenERPv6,openpg和openpwd是OpenERP服务器安装过程使用的默认用户名和密码。如果你计划变更这些默认设置,或者已经用不同的值安装了服务器,你需要用那些用户配置值创建用于OpenERP的PostgreSQL用户。

现在使用 pgAdmin III 创建数据库 “openerpdemo” ,数据库所有者是 “openpg”:

CREATE DATABASE openerpdemo WITH OWNER = openpg ENCODING = 'UTF8';
COMMENT ON DATABASE openerpdemo IS 'OpenERP Demo DB';

如果你已经安装了OpenERP服务器,那么现在你可以启动它了。如果需要,你可以在Windows控制窗,通过指定命令行选项,覆盖服务器配置。有关于此更多信息,参见这部分 定制配置.

在任何Windows版本,执行如下命令,改变用户密码:

net user <accountname> <newpassword>
e.g. net user postgres postgres

如果它是个域帐号,那么只要在后面添加 “/DOMAIN” 。

如果你想删除它, 只需要执行:

net user <accountname> /delete

大小写不敏感搜索问题

因为安装需要完全UTF8字符支持,考虑用postgres >= 8.2.x。使用这个之前的版本,OpenERP搜索合作伙伴、产品等将不会返回想要的大小写不敏感搜索结果。

例如:

SELECT 'x' FROM my_table WHERE 'bét' ilike 'BÉT'
--matches only in 8.2.x