I have my app working fine on local, but when I tried to connect to remote server I get this error: CLIENT_PLUGIN_AUTH is required.
server.port=8081
spring.jpa.hibernate.ddl-auto=none
#local
#spring.datasource.url=jdbc:mysql://localhost:3306/dbtest
#spring.datasource.username=user
#spring.datasource.password=password
#remote
spring.datasource.url=jdbc:mysql://userssh:[email protected]:3306/dbtest
spring.datasource.username=userRemote
spring.datasource.password=passRemote
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
I got it.
Step 1. Create an user on remote mysql server and grant all privileges.
Step 2. Change datasource url
spring.datasource.url=jdbc:mysql://xxx.xxx.xxx.xxx:3306/dbtest
Step 3. Change pom.xml mysql
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.6</version>
</dependency>
Check that version is changed to <version>5.1.6</version>
from <scope>runtime</scope>
you need to find a compatible version for your MySQL installed version
Default one is
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
Change it to some version
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.46</version>
</dependency>
Now remove the default dependency installed. "package explorer"> your project > "Maven dependencies">type MySql it will come, now delete it(mysql-connector-java-x.y.z.jar)
Try to give a version nearer to your MySql version & check maven repository and find a nearer version having more usage
For me, MySql version is 5.0.27 which you can see from "MySQL command-line client" and the version I tried is 5.1.46
1 more thing is to add to the application.proerties
spring.datasource.driver-class-name= com.mysql.jdbc.Driver
But, if you are taking MySql dependency version nearer to 8 it is
spring.datasource.driver-class-name= com.mysql.cj.jdbc.Driver
which is not required as it takes internally
Now do "clean install" your app, right-click "run as">mvn clean & "run as">mvn install, then build your application using right-click "maven">update project(Alt+F5)
Now to confirm version change, check maven dependency, mysql-connector-java-5.1.46.jar (whichever is your mentioned dependency)
And, if still not working make sure you have checked with some applications having localhost server. Then check /etc/drivers/hosts file & uncomment this line
# 127.0.0.1 localhost
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With