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 控制台,输入:

  1. C:\Program Files\PostgreSQL\9.0\bin>createuser.exe --createdb --username postgres --no-createrole --pwprompt openpg
  2. Enter password for new role: openpgpwd
  3. Enter it again: openpgpwd
  4. Shall the new role be a superuser? (y/n) y
  5. Password: XXXXXXXXXX
  6. * line 1 is the command itself
  7. * line 2 asks you the new user's password
  8. * line 3 asks you to confirm the new user's password
  9. * line 4 new role is superuser or not?
  10. * line 5 asks you the *postgres* user's password

选项解释:

  • --createdb : 新用户能创建新数据库

  • --username postgres : createuser 将使用 postgres 用户 (超级用户)

  • --no-createrole : 此用户不允许创建新用户

  • --pwprompt : createuser 将询问你新用户的密码

  • openpg : 新用户名,你可以使用其他用户名替换。

  • openpgpwd : 新用户密码,你可以使用其他用户密码替换。

注解

密码

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

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

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

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

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

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

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

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

  1. net user <accountname> /delete

大小写不敏感搜索问题

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

例如:

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