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

StackOverflow https://stackoverflow.com/questions/21730863

  •  10-10-2022
  •  | 
  •  

Question

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

Was it helpful?

Solution

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.

OTHER TIPS

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.

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.

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

...

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top