编程知识 cdmana.com

Record: com mysql. cj. jdbc. exceptions. CommunicationsException: Communications link failure... [effective through personal test]

author :bug bacteria

️ Blog :CSDN Nuggets etc.

official account : Ape circle wonderful house

important clause : Originality is not easy. , For reprint, please attach the original source link and this statement , Thank you for your cooperation .

Copyright notice : Some words or pictures in the article may come from the Internet or Baidu Encyclopedia , If there is infringement, please contact bug Bacterial treatment .

One 、 Preface

Environmental Science :jdk1.8 +mysql 5.6 + Alibaba cloud centos7.6 

Two 、 Wrong content

Complete screenshot of error report :

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

3、 ... and 、 Report errors and check

         It's quite out of line , My local development and online test environment share a database , Last second, it was still developing locally. It's good , Why did you call jar package , The operation will report the failure of database communication connection . I carefully checked the database connection and other configuration information , Completely consistent with the local , Then I checked the local and online ip And port , It's all accessible .navicat The connection is also normal . Be reasonable , There can be no problem , But denied access , puzzled . 

         I'll take the jar Run locally , It's normal .

        Then my brain hole suddenly became strange , It's not because the database doesn't have a remote connection ? Although I use this server ip Add slogan , But if the database does not have a remote connection ,ip It doesn't recognize , Recognize only localhost And 127.0.0.1, Then I realized , So I immediately went to check the existing users , Passwords and hosts allowed to connect , Sure enough ,Host The only corresponding is localhost And 127.0.0.1 These two , No wonder I use it ip Access not available . You can refer to the appendix at the end of the text .

Four 、 Solution

        take ip Change to localhost, But this only applies to mysql The service and the back-end service you deploy can only be on the same virtual machine . Or change it to localhost   It doesn't help .

        Re execute the start command to start .

        See the console printing seconds , I know it , The error report is ip The problem of , Although it's not hard to find , It's also easy to find the problem points by checking the problem , But if you read what I wrote , I believe you can locate and solve the problem at the first time , This is what reading this article can bring you .

5、 ... and 、 appendix

One more line is set here host by %.% This means that you are allowed to be arbitrary host visit . But this setting is generally not recommended , More dangerous , Prudent operation .

        ... ...

          All right. , The above is the passage of java Achieve access to the client ip All my teaching . If it helps you , Please don't forget to give bug bacteria [  Three companies support  ] yo . If you want to get more learning resources or want to communicate with more technology enthusiasts , You can pay attention to my official account. 『 Ape circle wonderful house 』, The backstage replies the key words to get the learning materials 、 Big factory surface 、 Interview templates and other massive resources , Just wait for you to get .


6、 ... and 、 At the end of the article

         If you want to learn more , Little friends can pay attention to bug I created a special column for you 《bug tuning 》, It's all my hands , Ongoing update , I hope I can help more friends .

        I am a bug bacteria , A procedural ape who wants to get out of the mountain and change his fate . There's a long way to go , Are waiting for us to break through 、 To challenge . Come on , friends , Let's cheer together ! The future can be expected ,fighting!

         Finally, I'll give you two words I like very much , Share with you !


️ Be what you want to be , No time limit , As long as willing , Anytime? start.

You can change... From now on , It can be the same , This matter , There are no rules , You can live your best .


​​​

If the article helps you , Just leave your Fabulous Well !(#^.^#);

If you like bug Sharing articles , Just... Please bug Bacteria point Focus on Well !(๑′ᴗ‵๑)づ╭~;

If you have any questions about the article , Please also at the end of the text Leaving a message. perhaps Add group Well 【QQ Communication group :708072830】;

Given the limited personal experience , All viewpoints and technical research points , If there is any objection , Please reply directly to participate in the discussion ( Do not make offensive remarks , thank you );

Copyright notice : Originality is not easy. , For reprint, please attach the original source link and this statement , copyright , Piracy must be investigated !!! thank you .

版权声明
本文为[Bug bacteria ¹]所创,转载请带上原文链接,感谢
https://cdmana.com/2022/134/202205141333559233.html

Scroll to Top