纵有疾风起
人生不言弃

MySQL error 1251的解决方法

在运行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

  

.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.”>http://dev..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
    ->  = 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  = OLD_PASSWORD(newpwd);

其二:

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

未经允许不得转载:起风网 » MySQL error 1251的解决方法
分享到: 生成海报

评论 抢沙发

评论前必须登录!

立即登录