Pycharm连接MySQL报错:RuntimeError: cryptography is required for sha256_password or caching_sha2_password

报错如下:


Pycharm连接MySQL报错:RuntimeError: cryptography is required for sha256_password or caching_sha2_password_第1张图片
image.png

报错原因:MySQL8.0版本以后采用caching_sha2_password作为默认的身份验证插件。

解决方法:

  1. 登录mysql:
mysql>mysql -u root -p 
Enter password:
  1. 查询用户密码:
mysql> select host,user,authentication_string from mysql.user;
  1. 设置(或修改)root用户密码:
ALTER user 'root'@'localhost' IDENTIFIED BY '123456';

如果以上还不能解决:
重新登陆MySQL输入以下命令:

use mysql;
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '新密码';
FLUSH PRIVILEGES;

重新启动pycharm并运行,问题解决。

你可能感兴趣的:(Pycharm连接MySQL报错:RuntimeError: cryptography is required for sha256_password or caching_sha2_password)