How to do it...

To test this, you can use telnet:

shell> telnet <mysql ip> 3306# if telnet is not installed you can install it or use nc (netcat)

If telnet hangs or the connection is refused, it means that the port is closed. Please note that if you see an output like this, it means that the port is not blocked:

shell> telnet 35.186.158.188 3306Trying 35.186.158.188...Connected to 188.158.186.35.bc.googleusercontent.com.Escape character is '^]'.FHost '183.82.17.137' is not allowed to connect to this MySQL serverConnection closed by foreign host.

It means that the port is open but MySQL is restricting the access.

When creating users, avoid giving access from anywhere (the % option). Restrict access to an IP range or subdomain. Also restrict ...

Get MySQL 8 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.