mysql鉴权方式_mysql鉴权协议的问题

Client does not support authentication protocol requested by server

1 -- 错误原因分析

今天上线系统时遇到的一个问题:可执行程序使用MySQL4.0.22版本提供的静态库编译,运行时数据库服务器是5.0.33版本,当程序真正执行连接数据库时,曝出下面的错误消息。

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

查询MySQL的帮助文档,它给出这样的提示

MySQL 5.1 uses an authentication protocol based on a password hashing algorithm that is incompatible with that used by older (pre-4.1) clients. If you upgrade the server from 4.0, attempts to connect to it with an older client may fail with the message

翻译过来大致原因是MySQL自4.1以后使用了不同的鉴权协议,该协议与4.1之前的版本有着很大的不同。所以如果你的客户端是4.1之前的版本,那么在连接高版本的数据库时就会出现这样的错误。

2 -- 解决方法

1、Upgrade all client programs to use a 4.1.1 or newer client library

升级客户端程序使用4.1.1或者更高版本的客户端库。

2、When connecting to the server with a pre-4.1 client program, use an account that still has a pre-4.1-style password

连接数据库时,使用升级以前已经存在的账户,这些账户使用早于4.1版本的密码格式。

3、Reset the password to pre-4.1 style for each user that needs to use a pre-4.1 client program

使用早于4.1版本的密码格式重新设置账户密码,函数SET PASSWORD和OLD_PASSWORD()用来完成修改。可以使用下面的任一方法来重置。

方法1:

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

方法2:

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

-> WHERE Host = 'some_host' AND User = 'some_user';

mysql> FLUSH PRIVILEGES;

3 -- 参考资料

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值