if you have ConfigServer Security & Firewall enabled in WHM , only a certain ports are allowed to come in/out.

By default mysql will be blocked, to unblock it you need to add 3306 as an allowed list

Go to ConfigServer Security & Firewall – > Firewall Configuration -> Add 3306 into TCP_IN list ( separated by comma)

like this: 20,21,22,25,53,80,110,143,443,465,587,993,995,2077,2078,2082,2083,2086,2087,2095,2096,3306