0

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.

user2250471
  • 1,002
  • 3
  • 10
  • 23
  • 2
    Possible duplicate of [MySQL remote connection fails with "unknown authentication method"](http://stackoverflow.com/questions/14612551/mysql-remote-connection-fails-with-unknown-authentication-method) – Roadirsh Nov 22 '15 at 02:01
  • The solution in the above question was to downgrade to PHP 5.2, which is not the solution I'm looking for. – user2250471 Nov 22 '15 at 02:05
  • Try switching to mysqlnd if you can. This should support the connection without issue. – Machavity Nov 22 '15 at 02:07
  • The right solution is to update your password in fact. – Roadirsh Nov 22 '15 at 02:12
  • How do I do that? I set a username and password when I created a new database. I've tried deleting the database and creating a new one, and changing the password. – user2250471 Nov 22 '15 at 02:14
  • try this answer http://stackoverflow.com/questions/1340488/mysql-php-incompatibility/1340538#1340538 – Roadirsh Nov 22 '15 at 02:16

0 Answers0