Symfony,通过控制台访问root用户的数据库

时间:2016-07-10 13:34:49

标签: php symfony doctrine

当我尝试使用:

创建数据库时,我遇到了这个问题
php bin/console doctrine:database:create

[Doctrine\DBAL\Exception\DriverException]                                         
An exception occured in driver: SQLSTATE[HY000] [1698] Access denied  for user 'r  
oot'@'localhost'  

我确信我的用户名和密码是正确的,因为我可以通过sql console访问Sql数据库。 这是我的symfony配置:

#config.yml
doctrine:
dbal:
    driver:   pdo_mysql
    host:     "%database_host%"
    port:     "%database_port%"
    dbname:   "%database_name%"
    user:     "%database_user%"
    password: "%database_password%"
    charset:  UTF8
    # 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                   


#parameters.yml
parameters:
database_host: 127.0.0.1
database_port: 3306
database_name: foreigners
database_user: root
database_password: Filip
mailer_transport: smtp
mailer_host: 127.0.0.1
mailer_user: null
mailer_password: null
secret: d0c1b2a4aff786d87c8900e1a9631184ddd600bf     

1 个答案:

答案 0 :(得分:1)

为了确保您具有所需的权限,我将尝试从SQL控制台创建数据库。