通過pycharm鏈接mysql數據庫時,查詢表報錯提示:
RuntimeError: 'cryptography' package is required for sha256_password or caching_sha2_password auth methods
方法1:重啟MySQL
① 以管理員身份,cmd中輸入命令行“net start MySQL80”(根據安裝的版本,MySQL80這里服務名稱不一樣),來啟動mysql

② 輸入 “mysql”,進入MySQL。

③ pycharm再次運行,不報錯了。
方法2:安裝cryptography包
報錯:RuntimeError: 'cryptography' package is required for sha256_password or caching_sha2_password auth methods
該錯誤提示的意思是:sha256_password和caching_sha2_password兩種加密方式需要cryptography。
所以只需要安裝一下cryptography包就可以了: pip install cryptography
① 首先,前提在任務管理器中,看到mysql是運行的。
② 打開cmd后,輸入命令“pip install cryptography”,安裝成功后,再次運行pycharm,不報錯了。
