You can try looking into the following mentioned potential reasons that might be causing the error you are facing.
Make sure that you edit the security groups and add a rule to allow remote access from your machine to your Amazon EC2 instance.
MySQL will create a root user id by default which is only accessible from localhost. Which means that root user id and password will not work for the remote machine. To resolve this, you have to allow the root user to access MySQL from a remote machine.
Also, verify if the local firewall of your machine is enabled or not. If not, then enable it and make sure that port 3306 is open.