开发者

Remote Mysql Server connection by PHP

While i execute following code:

$db_host = "<IP>";  // Host name
$db_user = "<usr>";  // User name of your database
$db_password = "<pass>";     // Password of your database
$db_name="<db name>";   // Database name

$con = mysql_connect($db_host,$db_user,$db_password);
mysql_select_db($db_na开发者_如何学Gome) or die("Cannot select database...");

It shows following errors:

Warning: mysql_connect() [function.mysql-connect]: OK packet 6 bytes shorter than expected in C:\wamp\www\limosbusesjets\connection.php on line 21

Warning: mysql_connect() [function.mysql-connect]: mysqlnd cannot connect to MySQL 4.1+ using old authentication in C:\wamp\www\limosbusesjets\connection.php on line 21 Cannot select database...


These errors generally happen when one is using PHP 5.3, and its new mysqlnd driver to connect to MySQL (which is often the case with PHP 5.3, as it's one of the new stuff introduced with 5.3 -- and "mysqlnd" is mentionned in your second error) : with those, you cannot connect to a MySQL database using the old-passwords system.

Which means you'll have to change the way your MySQL server deals with passwords, to switch to the "new" authentication system.

See, for instance :

  • Resolving the "OK packet 6 bytes shorter than expected"
  • MySQL PHP incompatibility.
  • Backward Incompatible Changes

Not sure it's what is causing the problem in your case, but that's one common MySQL related thing, with PHP 5.3, for those errors...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜