Premature end of data (mysqlnd_wireprotocol.c:553)
    文章作者:恒爱网络 阅读次数:7627 发布时间:2014-3-27

    某用户在我司PHP5.3空间 安装程序,该程序用PDO方式连接数据库(MYSQL5.5)时提示 Premature end of data (mysqlnd_wireprotocol.c:553)

    寻求我们予以协助处理,因此使用代码测试下

    <?
    $user="yyyy";
    $pass="yyyyyy";
    $dbh = new PDO('mysql:host=localhost;dbname=sqlyyyy', $user, $pass);
    ?>

    访问时果然爆出如此错误,具体完整错误如下:

    PHP Warning: PDO::__construct() [pdo.--construct]: Premature end of data (mysqlnd_wireprotocol.c:553) in D:\vhost

    \Web43268\wwwroot\upload\1.php on line 4 PHP Warning: PDO::__construct() [pdo.--construct]: OK packet 1 bytes shorter than

    expected in D:\vhost\Web43268\wwwroot\upload\1.php on line 4 PHP Fatal error: Uncaught exception 'PDOException' with message

    'SQLSTATE[HY000] [2000] mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication. Please use an administration

    tool to reset your password with the command SET PASSWORD = PASSWORD('your_existing_password'). This will store a new, and more

    secure, hash value in mysql.user. If this user is used in other scripts executed by PHP 5.2 or earlier you might need to remove

    the old-passwords flag from your my.cnf file' in D:\vhost\Web43268\wwwroot\upload\1.php:4 Stack trace: #0 D:\vhost

    \Web43268\wwwroot\upload\1.php(4): PDO->__construct('mysql:host=loca...', 'yyyy', 'yyyyyy') #1 {main} thrown in D:\vhost

    \Web43268\wwwroot\upload\1.php on line 4


    一开始怀疑是 PDO 组件未生效 ,检查发下并无错误。仔细研究了下错误提示,并通过测试发现此问题是由于PHP5.3下 连接数据库是用户的密码哈希加密方式是 MySQL 4.1+  ,但我们数据库账号密码 默认开通时 哈希是  MySQL 4.0 兼容模式。,因此在 PHP5.3空间里程序连接数据库,无法验证  4.0 兼容模式的 密码哈希 而导致的出错。因此到 PHPMYADMIN 里将 用户哈希改为 4.1 即可解决此问题了。