0

I have a problem with connection to my mySQL databases (via IntelliJ Ulitimate) – most probably problem with connection between windows and wsl2 (Ubuntu-20.04 distribution).

Problem is quiet simple – always after couple of minutes (15 – 30, sometimes more) of working with mySQL database onIntelliJ and some queries done my connection with database is broken (usually as a result of a simple query). Message appears: “java.net.ConnectException: Connection refused: connect.”

When I test connection (via localhost) the message is:

“[08S01] 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.

java.net.ConnectException: Connection refused: connect.”

Actually one thing which helps in 100% is restarting my laptop. Then, after starting MySQL everything runs great for next 20-30 minutes, until the same error of connection emerges.

Second solution is: terminating WSL (eg on PowerShell), restarting IntelliJ, starting MySQL - it works... but not always (ca 8/10 attempts) and since I must restarting IntelliJ is not very much conmfortable

I tried and didn't work:

  • simple restarting IntelliJ (also after stopping MySQL via terminal and starting again)

  • terminating WSL and then again starting a terminated WSL distro (but without restarting IntelliJ)

  • turning off windows defender firewall (and whole windows defender)

  • I also tried to connect not through localhost but through ip – and that doesn’t work at all (it doesn’t work even in this time when MySQL connection through localhost is OK (= eg. after restarting my computer) )

  • creating new user with all privilages

My Windows is updated, ping works.

EDIT: At the same time, everything works well, when I use mySQL from terminal command line (connection to database is OK).

As a beginner in Java I would be very thankful for any advice.

MazieKor
  • 1
  • 1
  • Does it work using mysql command from comand line outside IDE? – y.bedrov Nov 16 '20 at 08:31
  • yes, it works, when I use mysql from comand line. – MazieKor Nov 16 '20 at 18:15
  • Is it possible to share idea.log ("Help | Show Log in...") after facing the issue and restarting IDE? – y.bedrov Nov 17 '20 at 07:47
  • Hi, thanks for your question, unfortunatelly that is not possible at the moment. One of my friends adviced me (he thinks that it could be a problem with some Windows update) that I can uninstall mySQL and re-install again, but this time version on Windows (the one with the problem was for WSL). And that worked. So - the problem is partially solved - my connection is OK, the only issue is that MySQL is now under Windows, but for now this is actually no problem for me :) – MazieKor Nov 24 '20 at 02:15
  • I have the same problem with MySQL installed on WSL2. It would be nice if someone get a solution. – KrmX Sep 17 '21 at 21:41

0 Answers0