1

I have tried to connect to Amazon EC2 instance MySql from localhost.

Tried:

  • Granting privilege for user for remote connect

  • Made domain ping-able from outside.

  • Able to login through phpmyadmin with same credentials

  • Gone through lot of Stackoverflow answers.

$link = mysqli_connect('ec2-12-223-36-172.compute-1.amazonaws.com', 'myuser', 'xxxxxxxxxxx'); // mysqli_connect('domain', 'myuser', 'pasword', 'dbname', 3306); if (!$link) { die('Could not connect'); } echo 'Connected successfully'; exit; 

Warning: mysqli_connect(): (HY000/2002): Connection refused

10
  • By localhost, do you actually mean you are trying to connect from your local PC to the Amazon cloud Commented Mar 26, 2019 at 12:09
  • @RiggsFolly Yes exactly Commented Mar 26, 2019 at 12:12
  • Are you sure that your ec2 port 3306 is open to public? Commented Mar 26, 2019 at 12:17
  • 2
    This would require your database on EC2 to be exposed to the public internet. 1) You'd need to set it up this way, and 2) this is a terrible idea security wise. You typically tunnel into your EC2 machine using SSH and connect to the database through the tunnel. Commented Mar 26, 2019 at 12:18
  • 3
    Make your question about exactly that. Commented Mar 26, 2019 at 12:23

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.