Pepert
Pepert

Reputation: 11

Symfony error : Cannot connect to DB after DB update

I had my Symfony 2 website connected to a MySQL DB, everything was find, but after changing my contract with my host provider, I needed tu update my datas on a new DB, with new names. I created the new DB, php myAdmin shows me that everything is fine on that side.

I updated the paramaters.yml file as follow in my symfony project:

parameters:
database_host: newdbhostname.db.1and1.com
database_port: 3306
database_name: newdbname
database_user: newdbusername
database_password: **********
mailer_transport: mail
mailer_host: null
mailer_user: null
mailer_password: null
secret: *sameasbefore*

But since then, I cannot connect to the DB, and have this weird error:

Warning: PDO::__construct(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /homepages/37/d627732413/htdocs/billetterielouvre/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php on line 43

This part corresponds to:

    public function __construct($dsn, $user = null, $password = null, array $options = null)
    {
        try {
LINE 43 --> parent::__construct($dsn, $user, $password, $options);  
            $this->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('Doctrine\DBAL\Driver\PDOStatement', array()));
            $this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        } catch (\PDOException $exception) {
            throw new PDOException($exception);
        }
    }

I cleared the cache through ssh on the server, but still this error happens. Does anybody have an idea to help me find what needs to be fixes there ?

Thanks!

Upvotes: 0

Views: 749

Answers (1)

ste
ste

Reputation: 1539

You should clean the cache.

rm -rf app/cache/*

Does the new provider allow connecting from external networks?

Try creating a script in plain old PHP and see if you can connect

With SSH on the server, can you resolve the host of the db? Try nslookup newdbhostname.db.1and1.com and then telnet newdbhostname.db.1and1.com 3306

Upvotes: 1

Related Questions