如何将Odoo 13与PostgreSQL数据库连接?

时间:2019-11-11 10:04:43

标签: python postgresql odoo odoo-13

我正在使用Windows 10,PostgreSQL 12,Python 3.7.5。我创建用户名odoo,密码odoo,创建数据库mydb

源代码为https://github.com/odoo/odoo/tree/aa0554d224337e1d966479a351a3ed059d297765

我运行命令

python odoo-bin -r odoo -w odoo --addons-path=addons --db-filter=mydb$

错误

E:\source_code\github.com\xxxxxxxx\odoo>python odoo-bin -r odoo -w odoo --addons-path=addons --db-filter=mydb$
2019-11-11 09:20:31,240 7372 INFO ? odoo: Odoo version 13.0
2019-11-11 09:20:31,240 7372 INFO ? odoo: addons paths: ['E:\\source_code\\github.com\\xxxxxxxx\\odoo\\odoo\\addons', 'c:\\users\\xxxxxxxx\\appdata\\local\\openerp s.a\\odoo\\addons\\13.0', 'e:\\source_code\\github.com\\xxxxxxxx\\odoo\\addons', 'e:\\source_code\\github.com\\xxxxxxxx\\odoo\\odoo\\addons']
2019-11-11 09:20:31,241 7372 INFO ? odoo: database: odoo@default:default
2019-11-11 09:20:31,397 7372 INFO ? odoo.addons.base.models.ir_actions_report: You need Wkhtmltopdf to print a pdf version of the reports.
2019-11-11 09:20:31,517 7372 INFO ? odoo.service.server: HTTP service (werkzeug) running on D1CMPS_VyDN.mptelecom.com:8069
2019-11-11 09:20:45,250 7372 INFO ? odoo.http: HTTP Configuring static files
2019-11-11 09:20:45,296 7372 INFO ? odoo.sql_db: Connection to the database failed
2019-11-11 09:20:45,299 7372 INFO ? werkzeug: 192.168.50.215 - - [11/Nov/2019 09:20:45] "GET / HTTP/1.1" 500 - 0 0.000 0.039
2019-11-11 09:20:45,333 7372 ERROR ? werkzeug: Error on request:
Traceback (most recent call last):
  File "C:\Program Files\Python37\lib\site-packages\werkzeug\serving.py", line 270, in run_wsgi
    execute(self.server.app)
  File "C:\Program Files\Python37\lib\site-packages\werkzeug\serving.py", line 258, in execute
    application_iter = app(environ, start_response)
  File "E:\source_code\github.com\xxxxxxxx\odoo\odoo\service\server.py", line 414, in app
    return self.app(e, s)
  File "E:\source_code\github.com\xxxxxxxx\odoo\odoo\service\wsgi_server.py", line 142, in application
    return application_unproxied(environ, start_response)
  File "E:\source_code\github.com\xxxxxxxx\odoo\odoo\service\wsgi_server.py", line 117, in application_unproxied
    result = odoo.http.root(environ, start_response)
  File "E:\source_code\github.com\xxxxxxxx\odoo\odoo\http.py", line 1281, in __call__
    return self.dispatch(environ, start_response)
  File "E:\source_code\github.com\xxxxxxxx\odoo\odoo\http.py", line 1251, in __call__
    return self.app(environ, start_wrapped)
  File "C:\Program Files\Python37\lib\site-packages\werkzeug\wsgi.py", line 766, in __call__
    return self.app(environ, start_response)
  File "E:\source_code\github.com\xxxxxxxx\odoo\odoo\http.py", line 1415, in dispatch
    self.setup_db(httprequest)
  File "E:\source_code\github.com\xxxxxxxx\odoo\odoo\http.py", line 1338, in setup_db
    httprequest.session.db = db_monodb(httprequest)
  File "E:\source_code\github.com\xxxxxxxx\odoo\odoo\http.py", line 1499, in db_monodb
    dbs = db_list(True, httprequest)
  File "E:\source_code\github.com\xxxxxxxx\odoo\odoo\http.py", line 1466, in db_list
    dbs = odoo.service.db.list_dbs(force)
  File "E:\source_code\github.com\xxxxxxxx\odoo\odoo\service\db.py", line 378, in list_dbs
    with closing(db.cursor()) as cr:
  File "E:\source_code\github.com\xxxxxxxx\odoo\odoo\sql_db.py", line 649, in cursor
    return Cursor(self.__pool, self.dbname, self.dsn, serialized=serialized)
  File "E:\source_code\github.com\xxxxxxxx\odoo\odoo\sql_db.py", line 186, in __init__
    self._cnx = pool.borrow(dsn)
  File "E:\source_code\github.com\xxxxxxxx\odoo\odoo\sql_db.py", line 532, in _locked
    return fun(self, *args, **kwargs)
  File "E:\source_code\github.com\xxxxxxxx\odoo\odoo\sql_db.py", line 600, in borrow
    **connection_info)
  File "C:\Program Files\Python37\lib\site-packages\psycopg2\__init__.py", line 126, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: FATAL:  role "odoo" is not permitted to log in - - -
2019-11-11 09:20:45,442 7372 INFO ? odoo.sql_db: Connection to the database failed
2019-11-11 09:20:45,443 7372 INFO ? werkzeug: 192.168.50.215 - - [11/Nov/2019 09:20:45] "GET /favicon.ico HTTP/1.1" 500 - 0 0.000 0.057
2019-11-11 09:20:45,449 7372 ERROR ? werkzeug: Error on request:
Traceback (most recent call last):
  File "C:\Program Files\Python37\lib\site-packages\werkzeug\serving.py", line 270, in run_wsgi
    execute(self.server.app)
  File "C:\Program Files\Python37\lib\site-packages\werkzeug\serving.py", line 258, in execute
    application_iter = app(environ, start_response)
  File "E:\source_code\github.com\xxxxxxxx\odoo\odoo\service\server.py", line 414, in app
    return self.app(e, s)
  File "E:\source_code\github.com\xxxxxxxx\odoo\odoo\service\wsgi_server.py", line 142, in application
    return application_unproxied(environ, start_response)
  File "E:\source_code\github.com\xxxxxxxx\odoo\odoo\service\wsgi_server.py", line 117, in application_unproxied
    result = odoo.http.root(environ, start_response)
  File "E:\source_code\github.com\xxxxxxxx\odoo\odoo\http.py", line 1281, in __call__
    return self.dispatch(environ, start_response)
  File "E:\source_code\github.com\xxxxxxxx\odoo\odoo\http.py", line 1251, in __call__
    return self.app(environ, start_wrapped)
  File "C:\Program Files\Python37\lib\site-packages\werkzeug\wsgi.py", line 766, in __call__
    return self.app(environ, start_response)
  File "E:\source_code\github.com\xxxxxxxx\odoo\odoo\http.py", line 1415, in dispatch
    self.setup_db(httprequest)
  File "E:\source_code\github.com\xxxxxxxx\odoo\odoo\http.py", line 1338, in setup_db
    httprequest.session.db = db_monodb(httprequest)
  File "E:\source_code\github.com\xxxxxxxx\odoo\odoo\http.py", line 1499, in db_monodb
    dbs = db_list(True, httprequest)
  File "E:\source_code\github.com\xxxxxxxx\odoo\odoo\http.py", line 1466, in db_list
    dbs = odoo.service.db.list_dbs(force)
  File "E:\source_code\github.com\xxxxxxxx\odoo\odoo\service\db.py", line 378, in list_dbs
    with closing(db.cursor()) as cr:
  File "E:\source_code\github.com\xxxxxxxx\odoo\odoo\sql_db.py", line 649, in cursor
    return Cursor(self.__pool, self.dbname, self.dsn, serialized=serialized)
  File "E:\source_code\github.com\xxxxxxxx\odoo\odoo\sql_db.py", line 186, in __init__
    self._cnx = pool.borrow(dsn)
  File "E:\source_code\github.com\xxxxxxxx\odoo\odoo\sql_db.py", line 532, in _locked
    return fun(self, *args, **kwargs)
  File "E:\source_code\github.com\xxxxxxxx\odoo\odoo\sql_db.py", line 600, in borrow
    **connection_info)
  File "C:\Program Files\Python37\lib\site-packages\psycopg2\__init__.py", line 126, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: FATAL:  role "odoo" is not permitted to log in - - -

如何从源代码成功启动Odoo 13?

3 个答案:

答案 0 :(得分:2)

对于create a PostgreSQL user,请执行以下步骤:

  1. 将PostgreSQL的bin目录(默认为C:\Program Files\PostgreSQL\<version>\bin)添加到 您的PATH
  2. 使用pg admin gui创建具有密码的Postgres用户:

    • 打开 pgAdminIII
    • 双击服务器以创建连接。
    • 选择“编辑”‣“新建对象”‣“新登录角色”。
    • 角色中输入用户名名称字段(例如odoo)。
    • 打开定义标签并输入密码(例如odoo),然后单击确定

答案 1 :(得分:1)

我认为您需要配置数据库以信任您的IP地址:

pg_hba.conf中进行以下更改:

# IPv4 local connections:
host all all 127.0.0.1/32   trust
host all all MY_IP/24 trust

另请参阅this

答案 2 :(得分:0)

odoo 13一个默认的用户名odoo,该用户使用最新创建的db对其进行了后退操作。

您可以在配置文件中传递数据库配置

odoo 13 /debian/odoo.conf

[options]
; This is the password that allows database operations:
; admin_passwd = admin
db_host = False
db_port = False
db_user = odoo
db_password = False
;addons_path = /usr/lib/python3/dist-packages/odoo/addons

您可以设置数据库主机端口用户密码并使用它