1. 程式人生 > >mysql報錯RuntimeError: cryptography is required for sha256_password or caching_sha2_p

mysql報錯RuntimeError: cryptography is required for sha256_password or caching_sha2_p

報錯原因:mysql版本身份驗證出現問題引起的

官方解釋:https://dev.mysql.com/doc/refman/8.0/en/caching-sha2-pluggable-authentication.html

解決方法:

      1.查詢你的mysql資料庫中user表plugin列的值,是否如下

        

      如果跟圖中的值不同,請進行下面的操作

         1). ALTER USER 'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER; #修改加密規則 

         2).ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'; #更新一下使用者的密碼 

        3).FLUSH PRIVILEGES; #重新整理許可權

        4).再重置下密碼:alter user 'root'@'localhost' identified by '123456';

     2.重啟服務。

    3.完成

    ps:如果執行以上的操作bug並沒有解決,請再把default_authentication_plugin=mysql_native_password新增到配置中。