SQLSTATE [HY000] [1045]访问被拒绝用户'root'@'127.0.0.1'(使用密码:否)SYMFONY2

时间:2014-02-12 14:33:33

标签: mysql symfony deploying

所以我一直在研究一个symfony2项目,这一切都很好,然后我想在godaddy上托管它,但现在我收到了这个错误。我不明白它也不知道如何解决它。非常感谢。

  

SQLSTATE [HY000] [1045]拒绝访问用户'root'@'127.0.0.1'(使用密码:否)

这是我的 paramaters.yml 文件

# This file is auto-generated during the composer install
parameters:
    database_driver: pdo_mysql
    database_host: 127.0.0.1
    database_port: null
    database_name: symfony
    database_user: root
    database_password: 
    mailer_transport: smtp
    mailer_host: 127.0.0.1
    mailer_user: null
    mailer_password: null
    locale: en
    secret: 14bcde878eda1c3f56a59b62b13e820b7f94563d

这是我的 config.yml 文件

imports:
    - { resource: parameters.yml }
    - { resource: security.yml }

framework:
    #esi:             ~
    #translator:      { fallback: "%locale%" }
    translator: ~
    secret:          "%secret%"
    router:
        resource: "%kernel.root_dir%/config/routing.yml"
        strict_requirements: ~
    form:            ~
    csrf_protection: ~
    validation:      { enable_annotations: true }
    templating:
        engines: ['twig']
        #assets_version: SomeVersionScheme
    default_locale:  "%locale%"
    trusted_hosts:   ~
    trusted_proxies: ~
    session:
        # handler_id set to null will use default session handler from php.ini
        handler_id:  ~
    fragments:       ~
    http_method_override: true

# Twig Configuration
twig:
    debug:            "%kernel.debug%"
    strict_variables: "%kernel.debug%"

# Assetic Configuration
assetic:
    debug:          "%kernel.debug%"
    use_controller: false
    bundles:        [ ]
    #java: /usr/bin/java
    filters:
        cssrewrite: ~
        #closure:
        #    jar: "%kernel.root_dir%/Resources/java/compiler.jar"
        #yui_css:
        #    jar: "%kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar"

# Doctrine Configuration
doctrine:
    dbal:
        driver:   "%database_driver%"
        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, add the path in parameters.yml
        # e.g. database_path: "%kernel.root_dir%/data/data.db3"
        # path:     "%database_path%"

    orm:
        auto_generate_proxy_classes: "%kernel.debug%"
        auto_mapping: true

# Swiftmailer Configuration
swiftmailer:
    transport: "%mailer_transport%"
    host:      "%mailer_host%"
    username:  "%mailer_user%"
    password:  "%mailer_password%"
    spool:     { type: memory }

fos_user:
    db_driver: orm # other valid values are 'mongodb', 'couchdb' and 'propel'
    firewall_name: main
    user_class: CurrencyConverter\ConverterBundle\Entity\User1
sensio_framework_extra:
    view:
        annotations: false
fos_rest:
    param_fetcher_listener: true
    body_listener: true
    format_listener: true
    view:
        view_response_listener: 'force'

我现在收到了密码和用户名:

  

SQLSTATE [HY000] [2002] php_network_getaddresses:getaddrinfo失败:名称或服务未知

5 个答案:

答案 0 :(得分:6)

您需要在database_user文件中设置database_passwordparameters.yml值。您可以在提供给您的GoDaddy新帐户设置电子邮件中获取这些设置。

答案 1 :(得分:5)

您收到的错误消息很清楚,

  

SQLSTATE [HY000] [1045] 访问被拒绝用户'root'@'127.0.0.1'   (使用密码:否)

您需要设置正确的database_user&主机中使用的database_password中的parameters.yml。检查您的accont配置以获取正确的访问参数。

答案 2 :(得分:0)

这取决于您的托管服务提供商。有时当你有一个共享服务器托管用户名不是root用户时,它可能是{YOURGODADDYACCOUNT_root}或somthing。检查您的cpanel或plesk管理以获得正确的凭据。

答案 3 :(得分:0)

正如错误消息所说。您需要提供一些密码。就我而言,我刚刚在'root'文件中添加了parameters.yml密码:

...

database_user: root
database_password: root

...

答案 4 :(得分:0)

我将app / config / parameters.yml中的database_host参数更改为0.0.0.0,该错误消失了。