首页 > 数据库 > MySQL > 正文

PHP 5 连接 mysql 5 的认证协议问题

2024-07-24 12:56:06
字体:
来源:转载
供稿:网友

商业源码热门下载www.html.org.cn

mysql 4.1以后, 采用了一种新的用户认证协议, 对于老的客户端会出现不支持认证协议的错误, 以下是官方网站的解决方法﹔



1upgrade all client programs to use a 4.1.1 or newer client library.



更新客户端库,这需要更新php的扩展库,对于老的api php已经不提供了这样的扩展库了



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



使用以前建立的账号连接,对于在新的认证协议下建立的账户就不行了



3reset 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

-> '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.



这是一个不错的办法,新建立的账号采用老式的加密协议



4tell the server to use the older password hashing algorithm:

start mysqld with the --old-passwords option.



这样新认证协议的优点就没法使用了



5assign 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.


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表