Questions
Error in remote connection to MySQL 8.0 using mybatis plus to reverse generate entity class codegenerator
Exception in thread "main" java.lang.RuntimeException: java.sql.SQLNonTransientConnectionException: Public Key Retrieval is not allowed
at com.baomidou.mybatisplus.generator.config.DataSourceConfig.getConn(DataSourceConfig.java:170)
at com.baomidou.mybatisplus.generator.config.builder.ConfigBuilder.<init>(ConfigBuilder.java:110)
at com.baomidou.mybatisplus.generator.AutoGenerator.execute(AutoGenerator.java:96)
at com.dev.docker.config.CodeGenerator.main(CodeGenerator.java:125)
Caused by: java.sql.SQLNonTransientConnectionException: Public Key Retrieval is not allowed
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:110)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:836)
at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:456)
at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:246)
at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:199)
at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:677)
at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:228)
at com.baomidou.mybatisplus.generator.config.DataSourceConfig.getConn(DataSourceConfig.java:168)
... 3 more
reason
Official website: https://mysqlconnector.net/connection-options/
If the user account uses sha256_ Password authentication, transmission must protect the password; TLS is the preferred mechanism, but if it is not available, RSA public key encryption will be used. To specify the RSA public key of the server, use the serverrsapublickeyfile connection string setting, or set allowpublickeyretrieval = true to allow clients to automatically request the public key from the server. Note that allowpublickeyretrieval = true may allow malicious agents to perform mitm attacks to obtain plaintext passwords, so it is false by default and must be explicitly enabled.
Because allowpublickeyretrieval and allowpublickey retrieval are false by default, it is necessary to add “allowpublickeyretrieval = true” on the JDBC connection
Solutions
Add “allowpublickeyretrieval = true” to JDBC connection
jdbc:mysql://xxxx/xxx?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=UTF-8&useSSL=false&allowPublicKeyRetrieval=true
Read More:
- 【PTA:】 Error: class X is public should be declared in a file named X.java
- MySQL: if the remote connection using navicatip fails, prompt “is not allowed to connect to this MySQL server”
- ERROR 1148 (42000): The used command is not allowed with this MySQL version
- A simple method of generating secret key by GIT and configuring SSH public key
- Host is not allowed to connect to this MySQL server
- MySQL failed to add foreign key: SQL 1452 cannot add or update a child row:a foreign key constraint fails
- Apache Groovy——java.lang.NoSuchMethodError: x.x.x: method <init>()V not found
- Example of public key signature and verification generated with fabric case
- SSH Login: RSA host key for 192.168.x.x has changed and you have requested strict checking. Host key
- Microsoft OLE DB Provider for SQL Server error & #x27;80040e4d & #x27;
- Git still needs to enter the user name and password after configuring the public key
- Error: permission denied (public key, GSSAPI keyex, GSSAPI with MIC, password)
- SQL state [null]; error code [0]; Error; nested exception is java.sql.SQLException: Error] with root
- Failed to decrypt protected XML node “DTS:Password” with error 0x8009000B “Key not valid for use in …
- [reprint and save] MySQL does not set the primary key and uses the self growing ID method
- java.sql.SQLException: The Network Adapter could not establish the connection
- Error java.lang.IllegalArgumentException: Validation failed for query for method public abstract
- java.sql.SQLRecoverableException: IO Error: Connection reset
- An error is reported about import Java. SQL. *; problem
- Registry key Error: Java version has value ‘1.8‘, but ‘1.7‘ is required