Step 1: Update the Security Group inbound rule for the MySQL database to allow connection from the machine which will connect to the DB. In the following example, we setup the connection open to only one EC2 machine.
If EC2 instance is in the same virtual private network. Then you can use ifconfig to find the EC2 instance's private IP address and enable it's access to the MySQL database:
The following is an example: