<?php
mysql_connect("localhost","root","19821010") or die(mysql_error());
echo "Connected to MySQL<br />";
?>然后我保存成testdb.php文件
输入http://localhost/testdb.php出现如下错误,请高手们给解决一下:
Warning: mysql_connect() [function.mysql-connect]: Client does not support authentication protocol requested by server; consider upgrading MySQL client in H:\Program Files\Apache Group\Apache2\htdocs\testdb.php on line 2
Client does not support authentication protocol requested by server; consider upgrading MySQL client
以上的错误是什么意思,我该怎么解决,谢谢.本人刚学PHP.

解决方案 »

  1.   

    mysql> UPDATE mysql.user SET Password = OLD_PASSWORD('newpwd')
    -> WHERE Host = 'some_host' AND User = 'some_user';
    mysql> FLUSH PRIVILEGES;
      

  2.   

    UPDATE mysql.user SET Password = OLD_PASSWORD('newpwd')
      

  3.   

    以上密码修改后连接mysql可能会有错误MySQL返回: 
    #1251 - Client does not support authentication protocol requested by server; consider upgrading MySQL client 
    出现这种问题也只有在MYSQL4.1.x以上版本,用4.0.x就没问题了.
    原因是因为你使用的mysql服务器版本中使用了新的密码验证机制,这需要客户端的版本要在4.0以上,原来的密码函数被改为old_password ();,这样使用password()生成的密码在旧的版本上的客户端就不好使了,而PHP中的MYSQL客户端都是3.23的(当然,mysqli的扩展除外),问题就在这了。目前已知解决方法(假设密码是123,mysql存放在d盘):
    1. 进入命令行下,转到MYSQL目录的BIN目录下,进入MYSQL命令行模式(用户root,密码123):
      d:\mysql\bin>mysql -uroot -p123
    2. 输入命令:
      mysql>set password for 'root'@'localhost'=old_password('123'); 
    3. 退出MYSQL命令行:
      mysql>\q
    至此可正常使用新密码了。