Java 无法?加载?认证?插件?'caching_sha2_password'

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/50193771/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-10 23:29:01  来源:igfitidea点击:

Unable?to?load?authentication?plugin?'caching_sha2_password'

javamysqlnetbeans

提问by Vijay Kumar

I'm getting error

我收到错误

Cannot?establish?a?connection?to jdbc:mysql://localhost:3306/world?zeroDateTimeBehavior=convertToNull?using?com.mysql.jdbc.Driver?(Unable?to?load?authentication?plugin?'caching_sha2_password'.)

无法?建立?a?连接?到 jdbc:mysql://localhost:3306/world?zeroDateTimeBehavior=convertToNull?using?com.mysql.jdbc.Driver?(Unable?to?load?authentication?plugin?'caching_sha2_password'。 )

in netbean established the connection.

在netbean 中建立了连接。

enter image description here

在此处输入图片说明

回答by utpal416

The newer versions of MySQL default to caching_sha2_password. If you want to disable it then follow below steps

较新版本的 MySQL 默认为 caching_sha2_password。如果您想禁用它,请按照以下步骤操作

  1. Login in to your MYSQL console as root user like below.
  1. 以 root 用户身份登录到您的 MYSQL 控制台,如下所示。

eg mysql -u YOUR_ROOT_USER_NAME -p YOUR_ROOT_USER_PASSWORD

例如 mysql -u YOUR_ROOT_USER_NAME -p YOUR_ROOT_USER_PASSWORD

  1. Then execute the command by replacing YOUR_ROOT_USER_NAMEand YOUR_ROOT_USER_PASSWORD
  1. 然后通过替换YOUR_ROOT_USER_NAME和 执行命令YOUR_ROOT_USER_PASSWORD

ALTER USER 'YOUR_ROOT_USER_NAME'@'localhost' IDENTIFIED WITH mysql_native_password BY 'YOUR_ROOT_USER_PASSWORD';

ALTER USER 'YOUR_ROOT_USER_NAME'@'localhost' IDENTIFIED WITH mysql_native_password BY 'YOUR_ROOT_USER_PASSWORD';

You will no longer get any 'caching_sha2_password' exception while connecting for any client after this.

caching_sha2_password在此之后连接任何客户端时,您将不再收到任何“ ”异常。

回答by Hemanth Smarty

follow these steps:

按着这些次序:

  • just turn off the firewall on the system and security on control panel,
  • create a new dynamic web project
  • copy all the class fields and java files from the project
  • add jar in build path version 8.0
  • select tomcat in project facets
  • copy jAR in lib
  • try running jdbcconnection program
  • 只需关闭系统上的防火墙和控制面板上的安全性,
  • 创建一个新的动态 Web 项目
  • 从项目中复制所有类字段和 java 文件
  • 在构建路径版本 8.0 中添加 jar
  • 在项目方面选择 tomcat
  • 在 lib 中复制 jar
  • 尝试运行 jdbcconnection 程序

it will run.

它会运行。