您的位置:华夏互联>>数据库知识>>mysql 1251错误解决方法

mysql 1251错误解决方法

作者: 来源: 发布时间:2009-05-20 点击数:

今天重新安装mysql数据库,还是出现了以前遇见的1067错误,然后外加1251.

解决办法如下:

解决方法:
1、windows平台
    主要是改变连接MySQL的帐户的加密方式,MySQL4.1/5.0是通过PASSWORD这种方式加密的.可以通过以下两种方法得到解决:

    mysql->SET PASSWORD FOR 'some_user'@'some_host'=OLD_PASSWORD('new_password');
    mysql->UPDATE mysql.user SET Password=OLD_PASSWORD('new_password') WHERE Host='some_host' AND User='some_user'; 
 
这里的some-user以及后面的host填写自己的,new_password也填写自己的,后面的那句话就复制,然后粘贴打进去就可以了。
 
2、Unix平台
    linux平台下首先确定是否安装过MySQL的客户端,这个用rpm安装很简单:
    rpm -ivh MySQL-client-4.1.15-0.i386.rpm 
    然后在编译php的时候要加上: 
    --with-mysql=/your/path/to/mysql 
    一般情况下都可以解决。如果还出现这种错误,可以按照下面的方法来做: 
    mysql->SET PASSWORD FOR 'some_user'@'some_host'=OLD_PASSWORD('new_password'); 
    mysql->UPDATE mysql.user SET Password=OLD_PASSWORD('new_password') WHERE Host='some_host' AND User='some_user';
 
更多信息:
#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 you'll 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;

问题致此解决。
责任编辑: 发表评论>>