建站软件 优化软件 编程软件 网页辅助 站群程序 网站程序 图像处理 资源教程 字体下载 推荐软件


您的位置:首页 > MYSQL学习 > MySQL error 1251的解决方法

MySQL error 1251的解决方法

时间:2015-02-09 10:45:26  来源:免费模板网 作者:风雪 阅读次数 tagsMySQLerror1251

在运行mysql的时候有时候mysql会报出各种错误,本文介绍下error 1251的解决方案

虽然 MySQL 4.1.7 已经发布并成为官方推荐版本,但是 4.0.x 系列并没有停止更新和 bug 修复,其实现在服务器上的 MySQL 大多是 3.x 版本的,呵呵。

  在更新到 4.1.17 版本的 MySQL 后,发现需要使用 MySQLi 扩展方能正常使用数据库,否则会出现 1251 - Client does not support authentication protocol requested by server; consider upgrading MySQL client 的提示,这个很纳闷,我没有研究具体的问题,只是切换到 MySQLi 扩展,其实在给 root 加上密码前还是可以使用 MySQL 扩展的,可是给 root 加上密码后就出现了上述客户端版本太低的提示。

  目前已知解决方法:

先用root登录MYSQL服务器,执行

mysql>set password for user1@"localhost"=old_password(yourPassword);

  原因是因为你使用的mysql服务器版本中使用了新的密码验证机制,这需要客户端的版本要在4.0以上,原来的密码函数被改为old_password();,这样使用password()生成的密码在旧的版本上的客户端就不好使了,而PHP中的MYSQL客户端都是3.23的(当然,mysqli的扩展除外),问题就在这了。

  更新信息:ChangeLog

  下载mysql.com/downloads/mysql/4.0.html

转自:zhouzhens blog

#1251 - Client does not support authentication protocol requested by server; consider upgrading MySQL client

参考官方链接:sql.com/doc/mysql/en/Old_client.html">http://dev.mysql.com/doc/mysql/en/Old_client.html


官方的说法:

MySQL 4.1 and up uses an authentication protocol based on a password hashing algorithm that is incompatible with that used by older clients. If you upgrade the server to 4.1, attempts to connect to it with an older client may fail with the following message。

To solve this problem, you should use one of the following approaches:

Upgrade all client programs to use a 4.1.1 or newer client library. 
When connecting to the server with a pre-4.1 client program, use an account that still has a pre-4.1-style password. 
Reset the password to pre-4.1 style for each user that needs to use a pre-4.1 client program. This can be done using the SET PASSWORD statement and the OLD_PASSWORD() function: 
mysql> SET PASSWORD FOR
    -> _user@some_host">some_user@some_host = OLD_PASSWORD(newpwd);

Alternatively, use UPDATE and FLUSH PRIVILEGES: 
mysql> UPDATE mysql.user SET Password = OLD_PASSWORD(newpwd)
    -> WHERE Host = some_host AND User = some_user;
mysql> FLUSH PRIVILEGES;

Substitute the password you want to use for ``newpwd in the preceding examples. MySQL cannot tell you what the original password was, so youll need to pick a new one. 
Tell the server to use the older password hashing algorithm: 
Start mysqld with the --old-passwords option. 
Assign an old-format password to each account that has had its password updated to the longer 4.1 format. You can identify these accounts with the following query: 
mysql> SELECT Host, User, Password FROM mysql.user
    -> WHERE LENGTH(Password) > 16;

For each account record displayed by the query, use the Host and User values and assign a password using the OLD_PASSWORD() function and either SET PASSWORD or UPDATE, as described earlier. 
For additional background on password hashing and authentication, see section 5.5.9 Password Hashing in MySQL 4.1.

如果你升级mysql到4.1以上版本后遇到以上问题,请先确定你的mysql client 是4.1或者更高版本.(WINDOWS下有问题你就直接跳到下面看解决方法了,因为MYSQL 在WINDOWS是client和server一起装上了的)

请使用以下两种方法之一

其一:

mysql> SET PASSWORD FOR _user@some_host">some_user@some_host = OLD_PASSWORD(newpwd);

其二:

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

本文地址:https://www.freemoban.com/mysql/2015/0209/444.html

猜你喜欢
栏目推荐
模板推荐

Copyright:www.freemoban.com 免费模板网 All Rights Reserved 网站备案:辽ICP备19014872号-2   辽公网安备 21010602000376号  辽公网安备:42900402000182号

免责声明:本站部分资源来自互联网收集,版权归原创者所有,如果侵犯了你的权益,我们会及时删除侵权内容,联系QQ:1615187561 谢谢合作!