0

我试图将会话数据存储到 postgresql 数据库中。我必须准确地说,使用默认会话存储我有任何问题。

所以我按照这里的解释配置我的配置文件:http: //symfony.com/doc/current/cookbook/configuration/pdo_session_storage.html

    session:
        handler_id: session.handler.pdo

    parameters:
        pdo.db_options:
            db_table:    session
            db_id_col:   session_id
            db_data_col: session_value
            db_time_col: session_time

    pdo:
        class: PDO
        arguments:
            - "pgsql:dbname=%database_name%"
            - %database_user%
            - %database_password%

    session.handler.pdo:
        class:     Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler
        arguments: [@pdo, %pdo.db_options%]

然后当我清除缓存时出现此错误:

[PDOException]
SQLSTATE[08006] [7] FATAL: authentification peer ?chou?e pour l'utilisateur

这是我用于创建表会话的脚本:

CREATE TABLE session
(
  session_id character varying(255) NOT NULL,
  session_value text NOT NULL,
  session_time integer NOT NULL,
  CONSTRAINT session_pkey PRIMARY KEY (session_id )
)
WITH (
  OIDS=FALSE
);
ALTER TABLE session
  OWNER TO myuser;

没有人可以帮助我吗?

4

1 回答 1

0

PDO dsn 缺少主机:

session:
    handler_id: session.handler.pdo

parameters:
    pdo.db_options:
        db_table:    session
        db_id_col:   session_id
        db_data_col: session_value
        db_time_col: session_time

pdo:
    class: PDO
    arguments:
        - "pgsql:host=%database_host%;dbname=%database_name%"
        - %database_user%
        - %database_password%

session.handler.pdo:
    class:     Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler
    arguments: [@pdo, %pdo.db_options%]

没有主机值,我和你有同样的错误:

[PDOException]                                                              
SQLSTATE[08006] [7] FATAL:  Peer authentication failed for user "postgres"

希望这可以帮助

于 2013-07-10T08:37:04.527 回答