nc -zv db.example.com 3306
-z only scans, -v tells you the result. Add -w 3 for a three-second timeout.
Without netcat, bash can do it on its own:
timeout 3 bash -c '</dev/tcp/db.example.com/3306' && echo open || echo closed
For an HTTP port, curl -I https://example.com gives you the headers, which proves the port and the TLS at once.