Jump to content

"Link to database cannot be established" on SSL


jeremisiron

Recommended Posts

I had set up 2 installations of Prestashop: (1) the first was on a testing subdomain that DOESN'T use SSL (which worked), and (2) my live production environment which uses SSL (not working). I'm not sure that SSL is the main cause, but it might be.

The Testing installation (on non-SSL) worked fine: the install process worked with no issue (using the default 127.0.0.1 to connect to the db).

However on the Live installation (with SSL), during installation the server address "127.0.0.1" gave an error saying "Please refresh the page" when I try to test the connection. When I changed to "localhost", then it worked. The installation properly created the ps_ tables in my live database.

Localhost (with no port)

However once it came time to run the site after installation, I was getting a 500 error at my root URL (/shop). I turned on _PS_MODE_DEV_ = true to show the error message:

Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [1045] Access denied for user 'MYUSER'@'localhost' (using password: YES)' in /home/MYPATH/shop/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:43

127.0.0.1, 18765

Then in parameters.php I changed database_host to 127.0.0.1 and added database_port 18765 (for SSL), and now I get a Prestashop Exception:

Quote

 

Warning: Packets out of order. Expected 0 received 45. Packet size=4739923 in /home/MYPATH/shop/classes/db/DbPDO.php on line 84

Warning: PDO::__construct(): MySQL server has gone away in /home/MYPATH/shop/classes/db/DbPDO.php on line 84

Warning: PDO::__construct(): Error while reading greeting packet. PID=3102 in /home/MYPATH/shop/classes/db/DbPDO.php on line 84

Warning: Cannot modify header information - headers already sent by (output started at /home/MYPATH/shop/classes/db/DbPDO.php:84) in /home/MYPATH/shop/classes/exception/PrestaShopException.php on line 41

[PrestaShopException]

Link to database cannot be established: SQLSTATE[HY000] [2006] MySQL server has gone away
at line 127 in file classes/db/DbPDO.php

122. public function connect() 123. { 124. try { 125. $this->link = $this->getPDO($this->server, $this->user, $this->password, $this->database, 5); 126. } catch (PDOException $e) { 127. throw new PrestaShopException('Link to database cannot be established: ' . $e->getMessage()); 128. } 129. 130. $this->link->exec('SET SESSION sql_mode = \'\''); 131. 132. return $this->link;

 

It also keeps redirecting me to /install/ which is unexpected since I thought the install went well.

Any ideas?

Link to comment
Share on other sites

Turns out it was only an issue with PDO. My password had special characters like plus "+" and such, and so it worked for direct MySQL on the command line, but not PDO.

So I change the PW and tried it again and now it's mostly fine. It's still redirecting to /install, oddly enough.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...