PHP 5 串連 mysql 5 的認證協議問題

來源:互聯網
上載者:User
mysql|問題 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.




聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.