[SOLVED 2022] DBeaver Communication link failure

by Dillon -

DBeaver SQL Client

Are you having trouble connecting to a local MySQL database through DBeaver Community Edition? DBeaver fails to connect to a local MySQL database with the error “Communication link failure the last packet sent successfully to the server was 0 milliseconds ago“.

Here is a breakdown of this page:

Introduction

The problem isn’t with DBeaver, in fact, if you installed another MySQL GUI tool, this issue would still occur.

This error occurs when the port used by MySQL is busy. To fix the communication link failure in DBeaver, we need to assign a port to MySQL.

In the solution below I used a Linux machine running Ubuntu 20.04 and verified using a Windows machine running Ubuntu 18.04 through WSL2 (Windows Subsystem for Linux).

Where possible I have provided alternative methods for both macOS and Windows.

This post also assumes you already have the correct database drivers installed and have created the MySQL connection.

DBeaver Communication Link Failure

Solution – Fixing communication link failure in DBeaver

First, you will need to locate your my.cnf file.

The my.cnf file is the configuration file used by MySQL. This MYSQL configuration file can reside in different locations, depending on your system and how it was installed.

Below are some locations where your installation’s my.conf could be for different operating systems.

Location of MySQL my.cnf file on MacOS or Linux

On macOS and Linux, you can find the MySQL configuration file in either the users home directory or within the /etc directory.

  • ~/.my.cnf
  • /etc/my.cnf

Location of MySQL my.cnf file on Windows

On a Windows machine, the MySQL configuration file can be in either the Windows directory or the root of the C drive.

In some cases, the my.cnf file can actually be a ini file, like so:

  • C:\Windows\my.ini
  • C:\Windows\my.cnf
  • C:\my.ini
  • C:\my.cnf

Once you have located the file, open it with your preferred editor. I will be using Nano.

nano /etc/mysql/my.cnf

You may need to append sudo to the command if you require higher security privileges.

Edit MySQL cnf file

Once you have opened the file using an editor, go to the bottom of the file and add the following configuration:

[mysqld]
port=3306 # or any other port
bind-address=0.0.0.0

Set the port to a port you know is open and not in use. By default, MySQL uses port 3306, but you can change this to another open port if required.

Save the file using Ctrl+O.

Now restart MySQL, there are multiple ways to do this, depending on your environment.

Restart MySQL on macOS or Linux

/etc/init.d/mysqld restart
# or 
systemctl restart mysqld

Restart MySQL on Windows

  • Open ‘Run’ by using Win key + R
  • Type ‘services.msc’
  • Now search for MySQL based on the version that is installed.
  • Click on ‘restart

If you found this post useful, check out how to Create SSH Connections in DBeaver.

Did this solution work for you? Leave a comment with your results.

Dillon Smart

👋 Hey, I'm Dillon!

I’m a Full-Stack developer in the UK, building websites and applications for around 12 years, landing my first full-time job as a developer in 2015.

Feel free to reach out on Twitter!

Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.