title: Amazon EC2 To External Database
body: <p>I have started working on a new project. I have a requirement to connect to a remote MariaDB database that is not hosted on AWS from an Amazon EC2 instance.</p>
  
  <p>I have root access to the database but it is fairly locked down.
  I need to ssh into a Linux machine, sudo as the root user and then connect to the Maria DB instance which is fine</p>
  
  <p>Now I am trying to connect to it from an EC2 instance using the mysql command.
  I created a user on the MariaDB instance with access from localhost and anywhere</p>
  
  <pre><code>GRANT ALL ON *.* to user@'localhost' IDENTIFIED BY 'password'; 
  GRANT ALL ON *.* to user@'%' IDENTIFIED BY 'password'; 
  </code></pre>
  
  <p>Unfortunately that does not work.
  I checked the IP tables on the MariaDB instance and they are empty.</p>
  
  <p>Is there anything else I can try so that I can connect to this database?</p>
  
  <p><strong>Update</strong>
  Tried the following iptables and still no joy</p>
  
  <pre><code>Chain INPUT (policy ACCEPT)
  target     prot opt source               destination
  ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:mysql
  
  Chain FORWARD (policy ACCEPT)
  target     prot opt source               destination
  
  Chain OUTPUT (policy ACCEPT)
  target     prot opt source               destination
  ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:mysql 
  </code></pre>
  
  <p>Thank you
  Damien</p>