SQLSTATE[HY000] [1045] Access denied for user 'root'@'127.0.0.1' (using password: NO) SYMFONY2
Asked Answered
P

5

5

So I'be been working on a symfony2 project and it was all good, then i wanted to host it on godaddy but now I get this error. I don't understand it neither do I know how to fix it. thanks so much.

SQLSTATE[HY000] [1045] Access denied for user 'root'@'127.0.0.1' (using password: NO)

This is my paramaters.yml file

# 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

This is my config.yml file

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'

I got the password and username now I get:

SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known

Psycho answered 12/2, 2014 at 14:33 Comment(6)
Your pasword, username or database name are still wrong.Eunuchize
Yeah they were wrong, so I created a new user and a database now I get this weird error SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not knownPsycho
You probably have a typo in server address (database_host). Check it.Eunuchize
how to know the database_host?Psycho
It's most often the localhost. But it could be different, depending on hosting.Eunuchize
Nope, i tried that but it didn't workPsycho
U
6

Your database_user and database_password values need to be set in the parameters.yml file. You can get those settings in the GoDaddy new account setup email that gets provided to you.

Untread answered 12/2, 2014 at 15:9 Comment(0)
N
5

The error message you got is clear enough,

SQLSTATE[HY000] [1045] Access denied for user 'root'@'127.0.0.1' (using password: NO)

You need to set the right database_user & database_password in the parameters.yml used in your host. Check your accont configuration to get the right access parameters.

Nysa answered 12/2, 2014 at 14:43 Comment(0)
S
0

It depends on your hosting provider then . Sometimes when you have a shared server hosting the username is not root it could be {YOURGODADDYACCOUNT_root} or somthing. check your cpanel or plesk administration to get the right credentials.

Siloum answered 5/9, 2014 at 14:4 Comment(0)
D
0

As error message said. You need to provide some password. In my case, I just added 'root' for the password in parameters.yml file:

...

database_user: root
database_password: root

...
Damp answered 1/3, 2018 at 9:10 Comment(0)
A
0

I changed database_host parameter in app/config/parameters.yml to 0.0.0.0 and this error disappeared.

Avalanche answered 3/1, 2019 at 10:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.