I just bought a new domain and I'm trying to get my project online, but when I use PHP 5.6, I can't connect to MySQL (v. 5.5.32). I built on MAMP with MySQL v. 5.5.42 with PHP 5.6. Only when I downgrade to PHP 5.3 does it connect.
I get this error message for PHP 5.5 and 5.6:
20151121T204651: example.com/index.php
PHP Warning: PDO::__construct(): The server requested authentication method unknown to the client [mysql_old_password] in /hermes/bosnaweb13a/b235/dom.examplecom/public_html/resource/connect.php on line 9
PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client' in /hermes/bosnaweb13a/b235/dom.examplecom/public_html/resource/connect.php:9
Stack trace:
#0 /hermes/bosnaweb13a/b235/dom.examplecom/public_html
This is what I'm using to connect:
$config = array(
'host' => 'localhost',
'username' => 'myusername',
'password' => 'mypassword',
'dbname' => 'mydatabase'
);
$db = new PDO('mysql:host=' . $config['host'] . ';dbname=' . $config['dbname'], $config['username'], $config['password']);
$db -> exec("set names utf8");
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
While I can get it work with 5.3, I don't want to use that version of PHP.