连接到mysql数据库:PDO数据过早结束

时间:2014-07-01 15:14:30

标签: php mysql pdo connection nette

当我想把网站放到主机上时,我有问题。我正在使用nette,当我想连接时,我收到错误

PDO :: __ construct():数据过早结束(mysqlnd_wireprotocol.c:553)

我在这个db配置中使用nette框架:

dsn: 'mysql:host=dbhost;dbname=dbtable'
user: dbuser
password: dbpass

当我尝试经典连接时,它正常工作。我不知道该怎么办以及如何解决这个问题。

if($myslConnection = mysql_connect("dbhost", "dbuser", "dbpass")){
  echo("connected");
    mysql_select_db("dbtable",$myslConnection);
    $result = mysql_query("SELECT * FROM news", $myslConnection);

    while($resultItem = MySQL_Fetch_Row($result)){
         echo $resultItem[1]."<br>";
    }
}
else{
  exit("not connected");
}

编辑:错误我有什么

Warning: PDO::__construct() [pdo.--construct]: Premature end of data (mysqlnd_wireprotocol.c:553) in /var/www/html/unix/i/y/domainname.noveranet.cz/www/info.php on line 5

Warning: PDO::__construct() [pdo.--construct]: OK packet 1 bytes shorter than expected in /var/www/html/unix/i/y/domainname.noveranet.cz/www/info.php on line 5

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 /var/www/html/unix/i/y/domainname.noveranet.cz/www/info.php:5 Stack trace: #0 /var/www/html/unix/i/y/domainname.noveranet.cz/www/info.php(5): PDO->__construct('mysql:host=tran...', 'user', 'pass') #1 {main} thrown in /var/www/html/unix/i/y/domainname.noveranet.cz/www/info.php on line 5

0 个答案:

没有答案