Mysql – connecting to thesql internal to ec2

amazon ec2connectionMySQL

I have a db server db.example.com CNAME'd to its external ec2 domain ec2-some-ip.aws.com

I have a client ec2-another-ip.aws.com trying to connect to my db.example.com. I granted privileges:

grant all privileges on *.* to 'some_user'@'ec2-another-ip.aws.com';

and in the client try:

mysql -u some_user -h db.example.com

only to get:

ERROR 1130 (00000): Host 'my-client-internal-mac.compute-1.internal' is not allowed to connect to this MySQL server

So it obviously maps its external domain to the internet domain. So How do I get mysql to allow my client given the restriction below.

NOTE I can't use the internal ip as all these servers are ebs root mounted and i start/stop them all the time, so the internal ip changes, but i map an external elastic ip each time i spin it up so its external ip is always the same

Best Answer

The easy method is to grant access to someuser@%, which means "someuser from any host". This reduces security, but it may be good enough depending on your setup.

In particular, if your EC2 security settings don't allow public access on port 3306, this should be fine. The EC2 firewall will only allow access from machines launched by your account.