通过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
或者豆瓣源:pip3 install cryptography -i https://pypi.douban.com/simple
清华大学源:pip3 install cryptography -i https://pypi.tuna.tsinghua.edu.cn/simple