Score:0

Can't connect to remote MySQL (v. 8.0.33 | ubuntu 22.04.2)

dk flag

On the server with the operating system ubuntu 22.04.2 installed MySQL version 8.0.33 with the following configuration:

/etc/mysql/mysql.conf.d/mysqld.cnf

#
# The MySQL database server configuration file.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html
#
# Here is entries for some specific programs
# The following values assume you have at least 32M ram
#
[mysqld]
#
# * Basic Settings
#
user            = mysql
pid-file        = /var/run/mysqld/mysqld.pid
socket  = /var/run/mysqld/mysqld.sock
port            = 3306
datadir = /var/lib/mysql
#
#
# If MySQL is running as a replication slave, this should be
# changed. Ref https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_tmpd>
# tmpdir                = /tmp
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address            = 0.0.0.0
mysqlx-bind-address     = 0.0.0.0
#
# * Fine Tuning
#
key_buffer_size         = 16M
# max_allowed_packet    = 64M
# thread_stack          = 256K
#
#
# thread_cache_size       = -1
#
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover-options  = BACKUP
#
# max_connections        = 151
#
# table_open_cache       = 4000
#
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
#
# Log all queries
# Be aware that this log type is a performance killer.
# general_log_file        = /var/log/mysql/query.log
# general_log             = 1
#
# Error log - should be very few entries.
#
log_error = /var/log/mysql/error.log
log_error_verbosity = 3
#
# Here you can see queries with especially long duration
# slow_query_log                = 1
# slow_query_log_file   = /var/log/mysql/mysql-slow.log
# long_query_time = 2
# log-queries-not-using-indexes
#
# The following can be used as easy to replay backup logs or for replication.
# note: if you are setting up a replication slave, see README.Debian about
#       other settings you may need to change.
# server-id             = 1
# log_bin                       = /var/log/mysql/mysql-bin.log
# binlog_expire_logs_seconds    = 2592000
max_binlog_size   = 100M
# binlog_do_db          = include_database_name
# binlog_ignore_db      = include_database_name
#

sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf

● mysql.service - MySQL Community Server
     Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
     Active: active (running) since Wed 2023-06-28 22:25:07 +03; 6min ago
    Process: 2043942 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
   Main PID: 2043950 (mysqld)
     Status: "Server is operational"
      Tasks: 37 (limit: 77022)
     Memory: 369.5M
        CPU: 1.782s
     CGroup: /system.slice/mysql.service
             └─2043950 /usr/sbin/mysqld

journalctl -xeu mysql.service

░░ The job identifier is 40379 and the job result is done.
чэр 28 22:31:19 riven systemd[1]: mysql.service: Consumed 1.865s CPU time.
░░ 
░░ The unit mysql.service completed and consumed the indicated resources.
чэр 28 22:31:20 riven systemd[1]: Started MySQL Community Server.
░░ Subject: A start job for unit mysql.service has finished successfully
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░ 
░░ A start job for unit mysql.service has finished successfully.
░░ 
░░ The job identifier is 40379.

As you can see MySQL is working fine and I can connect to the database locally.

At the same time, port 3306 is open in the firewall:

ufw status

Status: active

To                         Action      From
--                         ------      ----
7346                       ALLOW       Anywhere                  
20                         DENY        Anywhere                  
21                         DENY        Anywhere                  
40000:50000/tcp            ALLOW       Anywhere                  
63940/tcp                  ALLOW       Anywhere                  
22                         DENY        Anywhere                  
62390/tcp                  ALLOW       Anywhere                  
3306                       ALLOW       Anywhere                  
7346 (v6)                  ALLOW       Anywhere (v6)             
20 (v6)                    DENY        Anywhere (v6)             
5438 (v6)                  DENY        Anywhere (v6)             
40000:50000/tcp (v6)       ALLOW       Anywhere (v6)             
63940/tcp (v6)             ALLOW       Anywhere (v6)             
21 (v6)                    DENY        Anywhere (v6)             
22 (v6)                    DENY        Anywhere (v6)             
62390/tcp (v6)             ALLOW       Anywhere (v6)             
3306 (v6)                  ALLOW       Anywhere (v6)             

In the firewall on the MikroTIK router, the port is also open and when checking the port on the sites, the system detects the port is open:

Port Checker

netstat -plant | grep 3306

tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      1352891/mysqld      
tcp        0      0 0.0.0.0:33060           0.0.0.0:*               LISTEN      1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:58800         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:55746         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:33418         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:39848         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:46750         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:59064         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:51772         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:54564         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:52302         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:35614         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:37432         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:60826         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:33426         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:42130         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:41456         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:41460         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:36806         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:35598         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:34444         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:38860         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:36408         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:35390         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:51960         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:43738         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:41452         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:54074         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:41412         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:34454         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:51952         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:40964         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:45992         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:35824         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:40960         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:41428         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:55762         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:50532         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:58294         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:34820         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:59480         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:57184         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:36818         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:43718         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:56458         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:33416         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:33284         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:43732         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:38978         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:57180         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:55758         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:60552         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:54072         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:44856         127.0.0.1:3306          ESTABLISHED 368580/Code --stand 
tcp        0      0 127.0.0.1:3306          127.0.0.1:33412         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:57182         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:42242         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:35774         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:35184         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:38870         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:60834         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:60844         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:38858         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:46758         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:40978         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:50702         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:35824         127.0.0.1:3306          ESTABLISHED 368580/Code --stand 
tcp        0      0 127.0.0.1:3306          127.0.0.1:55730         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:33112         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:36820         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:38874         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:52296         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:38420         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:38770         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:40164         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:45996         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:36790         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:49712         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:41442         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:44856         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:38880         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:34834         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:41430         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:60818         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:38984         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:50706         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:35630         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:41618         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:51780         ESTABLISHED 1352891/mysqld      
tcp        0      0 127.0.0.1:3306          127.0.0.1:40974         ESTABLISHED 1352891/mysqld      
tcp6       0      0 127.0.0.1:46750         127.0.0.1:3306          ESTABLISHED 883/java            
tcp6       0      0 127.0.0.1:34444         127.0.0.1:3306          ESTABLISHED 883/java            
tcp6       0      0 127.0.0.1:38870         127.0.0.1:3306          ESTABLISHED 829/java            
tcp6       0      0 127.0.0.1:55758         127.0.0.1:3306          ESTABLISHED 819/java            
tcp6       0      0 127.0.0.1:38874         127.0.0.1:3306          ESTABLISHED 819/java            
tcp6       0      0 127.0.0.1:51960         127.0.0.1:3306          ESTABLISHED 800/java            
tcp6       0      0 127.0.0.1:33416         127.0.0.1:3306          ESTABLISHED 825/java            
tcp6       0      0 127.0.0.1:42130         127.0.0.1:3306          ESTABLISHED 883/java            
tcp6       0      0 127.0.0.1:57180         127.0.0.1:3306          ESTABLISHED 829/java            
tcp6       0      0 127.0.0.1:49712         127.0.0.1:3306          ESTABLISHED 883/java            
tcp6       0      0 127.0.0.1:57182         127.0.0.1:3306          ESTABLISHED 829/java            
tcp6       0      0 127.0.0.1:59064         127.0.0.1:3306          ESTABLISHED 800/java            
tcp6       0      0 127.0.0.1:33418         127.0.0.1:3306          ESTABLISHED 800/java            
tcp6       0      0 127.0.0.1:38770         127.0.0.1:3306          ESTABLISHED 1997254/java        
tcp6       0      0 127.0.0.1:35614         127.0.0.1:3306          ESTABLISHED 847/java            
tcp6       0      0 127.0.0.1:41430         127.0.0.1:3306          ESTABLISHED 819/java            
tcp6       0      0 127.0.0.1:38858         127.0.0.1:3306          ESTABLISHED 800/java            
tcp6       0      0 127.0.0.1:35184         127.0.0.1:3306          ESTABLISHED 847/java            
tcp6       0      0 127.0.0.1:50702         127.0.0.1:3306          ESTABLISHED 847/java            
tcp6       0      0 127.0.0.1:34454         127.0.0.1:3306          ESTABLISHED 829/java            
tcp6       0      0 127.0.0.1:54564         127.0.0.1:3306          ESTABLISHED 1997254/java        
tcp6       0      0 127.0.0.1:50706         127.0.0.1:3306          ESTABLISHED 883/java            
tcp6       0      0 127.0.0.1:40964         127.0.0.1:3306          ESTABLISHED 825/java            
tcp6       0      0 127.0.0.1:41456         127.0.0.1:3306          ESTABLISHED 883/java            
tcp6       0      0 127.0.0.1:50532         127.0.0.1:3306          ESTABLISHED 800/java            
tcp6       0      0 127.0.0.1:60834         127.0.0.1:3306          ESTABLISHED 819/java            
tcp6       0      0 127.0.0.1:39848         127.0.0.1:3306          ESTABLISHED 883/java            
tcp6       0      0 127.0.0.1:40960         127.0.0.1:3306          ESTABLISHED 883/java            
tcp6       0      0 127.0.0.1:52296         127.0.0.1:3306          ESTABLISHED 847/java            
tcp6       0      0 127.0.0.1:51772         127.0.0.1:3306          ESTABLISHED 883/java            
tcp6       0      0 127.0.0.1:41460         127.0.0.1:3306          ESTABLISHED 800/java            
tcp6       0      0 127.0.0.1:36818         127.0.0.1:3306          ESTABLISHED 819/java            
tcp6       0      0 127.0.0.1:35598         127.0.0.1:3306          ESTABLISHED 800/java            
tcp6       0      0 127.0.0.1:41428         127.0.0.1:3306          ESTABLISHED 847/java            
tcp6       0      0 127.0.0.1:34834         127.0.0.1:3306          ESTABLISHED 800/java            
tcp6       0      0 127.0.0.1:33112         127.0.0.1:3306          ESTABLISHED 825/java            
tcp6       0      0 127.0.0.1:46758         127.0.0.1:3306          ESTABLISHED 800/java            
tcp6       0      0 127.0.0.1:40974         127.0.0.1:3306          ESTABLISHED 800/java            
tcp6       0      0 127.0.0.1:40978         127.0.0.1:3306          ESTABLISHED 847/java            
tcp6       0      0 127.0.0.1:41452         127.0.0.1:3306          ESTABLISHED 819/java            
tcp6       0      0 127.0.0.1:40164         127.0.0.1:3306          ESTABLISHED 800/java            
tcp6       0      0 127.0.0.1:51780         127.0.0.1:3306          ESTABLISHED 800/java            
tcp6       0      0 127.0.0.1:51952         127.0.0.1:3306          ESTABLISHED 825/java            
tcp6       0      0 127.0.0.1:35390         127.0.0.1:3306          ESTABLISHED 825/java            
tcp6       0      0 127.0.0.1:60818         127.0.0.1:3306          ESTABLISHED 800/java            
tcp6       0      0 127.0.0.1:55762         127.0.0.1:3306          ESTABLISHED 800/java            
tcp6       0      0 127.0.0.1:60552         127.0.0.1:3306          ESTABLISHED 1997254/java        
tcp6       0      0 127.0.0.1:45992         127.0.0.1:3306          ESTABLISHED 1997254/java        
tcp6       0      0 127.0.0.1:60826         127.0.0.1:3306          ESTABLISHED 825/java            
tcp6       0      0 127.0.0.1:38880         127.0.0.1:3306          ESTABLISHED 829/java            
tcp6       0      0 127.0.0.1:36790         127.0.0.1:3306          ESTABLISHED 800/java            
tcp6       0      0 127.0.0.1:38420         127.0.0.1:3306          ESTABLISHED 1997254/java        
tcp6       0      0 127.0.0.1:33284         127.0.0.1:3306          ESTABLISHED 825/java            
tcp6       0      0 127.0.0.1:33412         127.0.0.1:3306          ESTABLISHED 800/java            
tcp6       0      0 127.0.0.1:43738         127.0.0.1:3306          ESTABLISHED 883/java            
tcp6       0      0 127.0.0.1:36806         127.0.0.1:3306          ESTABLISHED 829/java            
tcp6       0      0 127.0.0.1:43732         127.0.0.1:3306          ESTABLISHED 819/java            
tcp6       0      0 127.0.0.1:56458         127.0.0.1:3306          ESTABLISHED 825/java            
tcp6       0      0 127.0.0.1:45996         127.0.0.1:3306          ESTABLISHED 1997254/java        
tcp6       0      0 127.0.0.1:43718         127.0.0.1:3306          ESTABLISHED 847/java            
tcp6       0      0 127.0.0.1:58294         127.0.0.1:3306          ESTABLISHED 825/java            
tcp6       0      0 127.0.0.1:54074         127.0.0.1:3306          ESTABLISHED 1997254/java        
tcp6       0      0 127.0.0.1:35630         127.0.0.1:3306          ESTABLISHED 829/java            
tcp6       0      0 127.0.0.1:41412         127.0.0.1:3306          ESTABLISHED 825/java            
tcp6       0      0 127.0.0.1:59480         127.0.0.1:3306          ESTABLISHED 847/java            
tcp6       0      0 127.0.0.1:41442         127.0.0.1:3306          ESTABLISHED 819/java            
tcp6       0      0 127.0.0.1:34820         127.0.0.1:3306          ESTABLISHED 847/java            
tcp6       0      0 127.0.0.1:42242         127.0.0.1:3306          ESTABLISHED 800/java            
tcp6       0      0 127.0.0.1:52302         127.0.0.1:3306          ESTABLISHED 825/java            
tcp6       0      0 127.0.0.1:36820         127.0.0.1:3306          ESTABLISHED 819/java            
tcp6       0      0 127.0.0.1:55730         127.0.0.1:3306          ESTABLISHED 800/java            
tcp6       0      0 127.0.0.1:35774         127.0.0.1:3306          ESTABLISHED 800/java            
tcp6       0      0 127.0.0.1:37432         127.0.0.1:3306          ESTABLISHED 829/java            
tcp6       0      0 127.0.0.1:58800         127.0.0.1:3306          ESTABLISHED 1997254/java        
tcp6       0      0 127.0.0.1:60844         127.0.0.1:3306          ESTABLISHED 829/java            
tcp6       0      0 127.0.0.1:57184         127.0.0.1:3306          ESTABLISHED 800/java            
tcp6       0      0 127.0.0.1:33426         127.0.0.1:3306          ESTABLISHED 829/java            
tcp6       0      0 127.0.0.1:38978         127.0.0.1:3306          ESTABLISHED 800/java            
tcp6       0      0 127.0.0.1:36408         127.0.0.1:3306          ESTABLISHED 1997254/java        
tcp6       0      0 127.0.0.1:38984         127.0.0.1:3306          ESTABLISHED 800/java            
tcp6       0      0 127.0.0.1:38860         127.0.0.1:3306          ESTABLISHED 825/java            
tcp6       0      0 127.0.0.1:54072         127.0.0.1:3306          ESTABLISHED 1997254/java        
tcp6       0      0 127.0.0.1:55746         127.0.0.1:3306          ESTABLISHED 847/java            
tcp6       0      0 127.0.0.1:41618         127.0.0.1:3306          ESTABLISHED 819/java    

However, when trying to connect to the database using DataGrip, an error appears:

[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.

More details in the logs:

idea.log

2023-06-26 22:34:52,336 [262405502]   INFO - ution.rmi.RemoteProcessSupport - /Applications/DataGrip.app/Contents/jbr/Contents/Home/bin/java -Djava.rmi.server.hostname=127.0.0.1 -Duser.timezone=UTC -Xmx2048m -Xms128m -Dfile.encoding=UTF-8 -classpath "/Applications/DataGrip.app/Contents/lib/util.jar:/Applications/DataGrip.app/Contents/lib/groovy-2.5.14.jar:/Applications/DataGrip.app/Contents/plugins/DatabaseTools/lib/jdbc-console.jar:/Users/riven/Library/Application Support/JetBrains/DataGrip2021.2/jdbc-drivers/MySQL ConnectorJ/8.0.25/mysql-connector-java-8.0.25.jar" com.intellij.database.remote.RemoteJdbcServer com.mysql.cj.jdbc.Driver 
2023-06-26 22:34:52,538 [262405704]   INFO - ution.rmi.RemoteProcessSupport - Port/ServicesPort/ID: 6001/52099/RemoteDriverImpla304eaa8 
2023-06-26 22:34:52,538 [262405704]   INFO - ution.rmi.RemoteProcessSupport -  
2023-06-26 22:34:52,555 [262405721]   INFO - atabaseCredentialsAuthProvider - Connecting as: ExBot 
2023-06-26 22:34:52,555 [262405721]   INFO - .DatabaseConnectionEstablisher - Connecting to: jdbc:mysql://91.149.xxx.xxx:3306/ExLandSite 
2023-06-26 22:35:08,444 [262421610]   WARN - .DatabaseConnectionEstablisher - Connecting to: jdbc:mysql://91.149.xxx.xxx:3306/ExLandSite 
2023-06-26 22:35:08,444 [262421610]   WARN - .DatabaseConnectionEstablisher - Connection reset 
2023-06-26 22:35:08,445 [262421611]   WARN - alects.mysql.MysqlErrorHandler - Connection reset 
java.net.SocketException: Connection reset
    at java.base/java.net.SocketInputStream.read(SocketInputStream.java:186)
    at java.base/java.net.SocketInputStream.read(SocketInputStream.java:140)
    at com.mysql.cj.protocol.ReadAheadInputStream.fill(ReadAheadInputStream.java:107)
    at com.mysql.cj.protocol.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(ReadAheadInputStream.java:150)
    at com.mysql.cj.protocol.ReadAheadInputStream.read(ReadAheadInputStream.java:180)
    at java.base/java.io.FilterInputStream.read(FilterInputStream.java:133)
    at com.mysql.cj.protocol.FullReadInputStream.readFully(FullReadInputStream.java:64)
    at com.mysql.cj.protocol.a.SimplePacketReader.readHeader(SimplePacketReader.java:63)
    at com.mysql.cj.protocol.a.SimplePacketReader.readHeader(SimplePacketReader.java:45)
    at com.mysql.cj.protocol.a.NativeProtocol.readMessage(NativeProtocol.java:540)
    at com.mysql.cj.protocol.a.NativeProtocol.readServerCapabilities(NativeProtocol.java:498)
    at com.mysql.cj.protocol.a.NativeProtocol.beforeHandshake(NativeProtocol.java:385)
    at com.mysql.cj.protocol.a.NativeProtocol.connect(NativeProtocol.java:1351)
    at com.mysql.cj.NativeSession.connect(NativeSession.java:157)
    at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:953)
    at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:823)
    at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:453)
    at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:246)
    at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:198)
    at com.intellij.database.remote.jdbc.helpers.JdbcHelperImpl.connect(JdbcHelperImpl.java:629)
    at com.intellij.database.remote.jdbc.helpers.MysqlBaseJdbcHelper.connect(MysqlBaseJdbcHelper.java:179)
    at com.intellij.database.remote.jdbc.impl.RemoteDriverImpl.connect(RemoteDriverImpl.java:54)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:359)
    at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200)
    at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)
    at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:562)
    at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:796)
    at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:677)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:676)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:829)
    Suppressed: com.intellij.database.util.AsyncTask$Frame$FrameData: Async frame data: Test Connection -> Prepare connection -> Establish database connection -> Get database credentials -> Perform database connection
2023-06-26 22:35:08,445 [262421611]   INFO - ution.rmi.RemoteProcessSupport - Terminating: 127.0.0.1:6001/RemoteDriverImpla304eaa8 
2023-06-26 22:35:08,485 [262421651]   INFO - ution.rmi.RemoteProcessSupport - Process finished with exit code 137 (interrupted by signal 9: SIGKILL) 

I tried to test the connection via telnet:

telnet 91.149.xxx.xxx 3306
Trying 91.149.xxx.xxx...
Connected to leased-line-91-149-xxx-xxx.telecom.by.
Escape character is '^]'.
Connection closed by foreign host.

When checking the validity of the mysql config it outputs the following:

mysqld --validate-config
2023-06-28T19:31:32.936163Z 0 [Note] [MY-013667] [Server] Error-log destination "stderr" is not a file. Can not restore error log messages from previous run.
2023-06-28T19:31:32.939545Z 0 [Note] [MY-010747] [Server] Plugin 'FEDERATED' is disabled.
2023-06-28T19:31:32.939929Z 0 [Note] [MY-010733] [Server] Shutting down plugin 'MyISAM'
2023-06-28T19:31:32.939955Z 0 [Note] [MY-010733] [Server] Shutting down plugin 'CSV'

It is worth noting that when I check the port via portchecker.co/checking - packets reach the router (I can see this through the router interface), when I try to connect via DataGrip or telnet - packets do not reach the router.

I don't understand why I can't connect to my database, I've tried a huge number of articles on the internet - nothing works. I've tried everything else..

uz flag
Jos
You need to specify a `bind-address` for the server to listen to. Currently it is `0.0.0.0` meaning localhost only. Replace that by the server's network address.
uz flag
Jos
Does this answer your question? [Cannot remotely connect to MySQL](https://askubuntu.com/questions/608842/cannot-remotely-connect-to-mysql)
Riven avatar
dk flag
If I change the bind_address to my static external ip - then the following error occurs: Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xeu mysql.service" for details. If I change the ip address of the local machine, the mysql service starts, but there is still no connection to the database
uz flag
Jos
You may have made an error in the config file. Try `mysqld --validate-config`.
Riven avatar
dk flag
Jos, And the above article does not refer to this problem. It does not work in my case.
Riven avatar
dk flag
Jos, This is what I got when I tried to check the config file: 2023-06-28T19:31:32.936163Z 0 [Note] [MY-013667] [Server] Error-log destination "stderr" is not a file. Can not restore error log messages from previous run. 2023-06-28T19:31:32.939545Z 0 [Note] [MY-010747] [Server] Plugin 'FEDERATED' is disabled. 2023-06-28T19:31:32.939929Z 0 [Note] [MY-010733] [Server] Shutting down plugin 'MyISAM' 2023-06-28T19:31:32.939955Z 0 [Note] [MY-010733] [Server] Shutting down plugin 'CSV'
uz flag
Jos
Anything interesting in `systemctl status mysql.service` and `journalctl -xeu mysql.service`?
uz flag
Jos
Please, add this information to your question. It makes the comments unreadable.
Riven avatar
dk flag
Jos, i add this information to my question.
Score:0
dk flag

I found a solution for myself. Changing the port in mysql configuration helped me. I just changed the port to a different one, opened it in the router and everything worked, I can connect to the database and I can manage it.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.