doulei8861 2017-08-13 18:28
浏览 119

连接到在Ubuntu AWS实例中创建的MySQL数据库

Ok so I created an ubuntu instance from AWS and downloaded LAMP on it as you would in a regular Ubuntu OS. When I try to connect to the db from my php script it's rejecting the connection. saying "Connection failed: Connection refused". So I guess my question is this: Does amazon not allow you to connect to a db without using their RDS database service or am I putting something wrong here? (I've hidden some of the data for security purposes, the ... are numbers of my instance). When I put "" into the browser the apache message comes up so I don't see why this is not working as a server name?

$servername = "";

$username = "root";

$password = “hidden"; 

$dbname = "questions87";

// Create connection

$conn = mysqli_connect($servername, $username, $password, $dbname);

// Check connection

if (!$conn) {

  die("Connection failed: " . mysqli_connect_error());

  • 写回答

1条回答 默认 最新

  • doudoulb1234 2017-08-13 19:57

    You need to change your EC2 Security Group Inbound Rules related with 3306, you can find that on the AWS FAQ. Then, you need to be sure that your user@YOURIP have all permissions on your MySQL database. For your Inbound Rules it is recommended to use a Custom Rule to your IP, not All Traffic.

    Reference and further reading:

    本回答被题主选为最佳回答 , 对您是否有帮助呢?



    • ¥20 python 3des pyDes库
    • ¥15 关于#mysql#安装失败的问题。MySQL
    • ¥15 想问一下for循环计算表达式的方法,第一次接触
    • ¥15 如何在VA框架上面加功能,去读取框架内任何app数据功能
    • ¥15 关于#c语言#的问题:用c或c++写一个计算下列问题有关软件工程的代码并加上分析
    • ¥15 Zeppelin0.10.0版本升级lib包下的shiro-web
    • ¥15 链表入队的指针内存问题
    • ¥20 vba如何写本地html文件执行js
    • ¥15 VS2022的C#如何创建
    • ¥20 关于#用户注册#的问题,如何解决?