MySQL remote connection fails with “unknown authentication method”

前端 未结 7 1214
名媛妹妹
名媛妹妹 2020-11-28 15:22

I am trying to remotely connect to MySQL server online from my local machine, but I am getting the following error:

Warning: PDO::__construct(): The server r         


        
7条回答
  •  囚心锁ツ
    2020-11-28 15:46

    I ran into this same problem and figured out the problem had indeed to do with PHP.

    The solution was simple for me: switch to mysqli instead of PDO. When using Zend_Db, this is as easy as changing 1 line:

    $db = Zend_Db::factory('pdo_mysql',array('host' => MYSQL_HOST, 'username' => MYSQL_USER, 'password' => MYSQL_PASS, 'dbname' => MYSQL_SCHEMA));
    

    Becomes

    $db = Zend_Db::factory('mysqli',array('host' => MYSQL_HOST, 'username' => MYSQL_USER, 'password' => MYSQL_PASS, 'dbname' => MYSQL_SCHEMA));
    

    But if you application is not using the Zend_Db abstraction (or any other) layer, you could be in trouble.

提交回复
热议问题