PHP connecting to MYSQL

0

Hi all,

Total noob with web services. I'm trying to connect a php script to a AWS MYSQL server.

I can get a connection via MySQL workbench using the same settings I'm trying to use with a php script. The PHP script is failing.

This is the error I'm getting:
Connection failed: Can't connect to MySQL server on 'sayings.cfb0xnn82xyg.ap-southeast-2.rds.amazonaws.com' (111 "Connection refused")

I've set the public accessibility to yes.

For the subnet and security, I've left it as default, but I have no options in the Network & Security drop down menu to change.

I changed the security group using this website. https://docs.aws.amazon.com/vpc/latest/userguide/VPC_SecurityGroups.html#AddRemoveRules
The default is set to 0:0:0:0/0 and ::/0 which from my understanding should allow anyone to access the database.

I'm guessing my PHP script is okay because is copied verbatim from another site.

Any help would be appreciated. I just want a really simple connection to a database to pull data from to go to C#(Unity). Or if someone else has a simpler way than using a PHP script I would be really appreciative.

Web connections are not my strength if you can keep it low level as possible it would be appreciated.

cheers,

Steve

<?php $servername = "********.0xnn86xyg.ap-southeast-2.rds.amazonaws.com"; $username = "Shendo"; $password = "*******"; $dbname = "exams"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } ?>

Edited by: shendo on Feb 18, 2020 3:14 PM

Edited by: shendo on Feb 18, 2020 3:54 PM

shendo
asked 5 years ago1284 views
No Answers

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions