0

星期一好!我有一个可用的 Symfony2 Proyect,在我的计算机 (MacO) 上开发,以前也部署在 heroku 中,但是当我使用 apache Vhost 部署在 CentOS 中时。我的网站工作,但数据库连接不工作。我的 parameters.yml 文件:

# This file is auto-generated during the composer install
parameters:
    database_host: 127.0.0.1
    database_port: null
    database_name: dbname
    database_user: dbuser
    database_password: 8xFfdsaFDSCK

我的 config.yml 文件:

# Doctrine Configuration
doctrine:
    dbal:
        driver:   pdo_mysql
        host:     "%database_host%"
        port:     "%database_port%"
        dbname:   "%database_name%"
        user:     "%database_user%"
        password: "%database_password%"
        charset:  UTF8
        server_version: 5.6
        # if using pdo_sqlite as your database driver:
        #   1. add the path in parameters.yml
        #     e.g. database_path: "%kernel.root_dir%/data/data.db3"
        #   2. Uncomment database_path in parameters.yml.dist
        #   3. Uncomment next line:
        #     path:     "%database_path%"

    orm:
        auto_generate_proxy_classes: "%kernel.debug%"
        naming_strategy: doctrine.orm.naming_strategy.underscore
        auto_mapping: true

我的 config_prod.yml

imports:
    - { resource: config.yml }

#framework:
#    validation:
#        cache: validator.mapping.cache.apc
#    serializer:
#        cache: serializer.mapping.cache.apc

#doctrine:
#    orm:
#        metadata_cache_driver: apc
#        result_cache_driver: apc
#        query_cache_driver: apc

monolog:
    handlers:
        main:
            type:         fingers_crossed
            action_level: error
            handler:      nested
        nested:
            type:  stream
            path:  "%kernel.logs_dir%/%kernel.environment%.log"
            level: debug
        console:
            type:  console

而且我仍然在数据库连接上遇到错误:

[Doctrine\DBAL\Exception\ConnectionException]                                                                      
  An exception occured in driver: SQLSTATE[HY000] [1045] Access denied for user ''@'localhost' (using password: NO) 

我缺少什么来告诉用户、密码和数据库?

4

0 回答 0