Connecting MySQL remote url to spring boot application

时间:2019-03-17 22:42:34

标签: mysql spring-boot phpmyadmin

I am trying to connect to my remote MySQL database which is on the server, in my application.properties I have following config

spring.jpa.hibernate.ddl-auto=create
spring.datasource.url=jdbc:mysql://www.mydomain.com:3306/my_database_name
spring.datasource.username=my_username
spring.datasource.password=my_password

But i get this error

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. 

Can anyone please tell me what am i doing wrong ?

1 个答案:

答案 0 :(得分:0)

  1. 确保在MySQL服务器上启用了远程连接(尝试使用上面的用户名和密码从本地计算机从工作台或其他sql客户端进行连接,以测试远程连接是否处于活动状态。如果未处于活动状态,则激活
  2. 确保在服务器上(服务器的防火墙中)打开了端口3306
  3. 确保域名正确解析(ping www.my_domain.com