已解决使用Navicat连接MySQL数据库时报错Client does not support authentication protocol requested by server; cons(代

Posted iliuqiang

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了已解决使用Navicat连接MySQL数据库时报错Client does not support authentication protocol requested by server; cons(代相关的知识,希望对你有一定的参考价值。

报错缘由:

  起初在验证一个mybatis的demo时提示“Error querying database”(见下方完整代码),找了很多方法没有解决,最后在贴吧找到答案。错误原因是安装mysql时Authentication Method选择了第一种强加密方法,改成第二种问题就解决了。

解决方法:

  1. 打开mysql安装程序(或者重装,但是重装很麻烦),重新配置MySQL Server技术分享图片
  2. 配置Authentication Method这一步时,选择第二种加密方法,重新打开Navicat,问题解决。技术分享图片

参考资料: 贴吧13楼答案:http://tieba.baidu.com/p/5658058140

完整错误代码:

Exception in thread "main" org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database.  Cause: com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException: Client does not support authentication protocol requested by server; consider upgrading MySQL client
### The error may exist in com/how2java/pojo/Category.xml
### The error may involve com.how2java.pojo.listCategory
### The error occurred while executing a query
### Cause: com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException: Client does not support authentication protocol requested by server; consider upgrading MySQL client
    at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:150)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:141)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:136)
    at com.how2java.TestMybatis.main(TestMybatis.java:22)
Caused by: com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException: Client does not support authentication protocol requested by server; consider upgrading MySQL client
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:921)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2985)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:885)
    at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:3421)
    at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1247)
    at com.mysql.jdbc.Connection.createNewIO(Connection.java:2775)
    at com.mysql.jdbc.Connection.<init>(Connection.java:1555)
    at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:285)
    at java.sql.DriverManager.getConnection(DriverManager.java:664)
    at java.sql.DriverManager.getConnection(DriverManager.java:208)
    at org.apache.ibatis.datasource.unpooled.UnpooledDataSource.doGetConnection(UnpooledDataSource.java:201)
    at org.apache.ibatis.datasource.unpooled.UnpooledDataSource.doGetConnection(UnpooledDataSource.java:196)
    at org.apache.ibatis.datasource.unpooled.UnpooledDataSource.getConnection(UnpooledDataSource.java:93)
    at org.apache.ibatis.datasource.pooled.PooledDataSource.popConnection(PooledDataSource.java:385)
    at org.apache.ibatis.datasource.pooled.PooledDataSource.getConnection(PooledDataSource.java:89)
    at org.apache.ibatis.transaction.jdbc.JdbcTransaction.openConnection(JdbcTransaction.java:138)
    at org.apache.ibatis.transaction.jdbc.JdbcTransaction.getConnection(JdbcTransaction.java:60)
    at org.apache.ibatis.executor.BaseExecutor.getConnection(BaseExecutor.java:336)
    at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:84)
    at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:62)
    at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:324)
    at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156)
    at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:109)
    at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:83)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:148)
    ... 3 more

Process finished with exit code 1

 

以上是关于已解决使用Navicat连接MySQL数据库时报错Client does not support authentication protocol requested by server; cons(代的主要内容,如果未能解决你的问题,请参考以下文章

解决Navicat连接MySQL数据库报错问题

MySQL连接Navicat时报错常见的几种情况

用 Navicat插入 mysql 数据 插入中文时报错

mariadb/mysql使用Navicat连接报错

连接RDS MySQL时报错has more than ‘max_user_connections‘已解决

Navicat For MySQL中插入数据时报错1055?