1. First check if Mysql is running:
    systemctl status mysqld, if it shows not started, you need to start mysql.

  2. Check if the firewall is open, and if port 3306 is open.
    sudo firewall-cmd --list-all
    If 3306 is not open below, then open port 3306.

1
2
3
4
5
6
7
8
9
10
11
12
13
public
target: default
icmp-block-inversion: no
interfaces:
sources:
services: dhcpv6-client ssh
ports: 3306/tcp
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:

sudo firewall-cmd --zone=public --add-port=3306/tcp --permanent If added successfully, it shows success.

  1. Local test to see if connection is successful telnet ip 3306. It shows connection implemented but ping ip is successful.

  2. Later I realized this is a cloud server, it might be related to the inbound rules set on the web page.

  3. Opened Tencent Cloud’s inbound/outbound rule settings and found port 3306 was not open. Opened the port.

  4. Re-used telnet and connected successfully.

  5. Logged in using DataGrip, test connection successful.
    Image Description