简体   繁体   中英

Can't access my AWS hosted database using PHP

I am having a huge issue with accessing my AWS database from within the php code for a site i am building. I have tried many different connection methods, and all seem to give an error that says

    Warning: mysqli_connect(): (HY000/2003): Can't connect to MySQL server on '(the endpoint of my hosted DB)' (111)

I've looked up error 111, but I can not seem to understand why it applies to me in this scenario. I can access my database from any computer, using the same information I'm using here to try to connect. I'm starting to think it's the host I'm using for my site that's the problem. I'm using the free biz.nf host just for testing, but I'm not sure my site host really should have any effect on the php inside my site. Here's my connect statement

    $mysql_host="DB endpoint";
    $mysql_user="myusername";
    $mysql_pass="mypassword";
    $my_db="myDBname";

    $con = mysqli_connect($mysql_host,$mysql_user,$mysql_pass);

    if (mysqli_connect_errno())
    {
         echo "Failed to connect to MySQL: " . mysqli_connect_error();
    } 

Thanks for the help!

You likely need to update your security group and route tables for your subnets to allow the host on biz.nf to access the RDS instance.

Check your RDS dashboard for the given instance, and examine the settings on your security group and subnets.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM