1 Answer
- Newest
- Most votes
- Most comments
1
To solve this issue:
if you're getting a fatal error
eg: "mysqli_connect not defined"
first make sure you have php-mysql installed
if you don't, you can install it using
sudo apt-get install php-mysql -y
or
yum install php-mysql
Note: Connect to hostname "localhost" not your amazon server url
Also make sure that you have port 3306 opened on your inbound rules
to add new rule on your instance
-
goto security groups
-
click create security group
-
add inbound rule
-
select mysql/ (default port 3306 will be selected on port field)
with all that done, make your connection in this way;
<?php $servername = "localhost"; $username = "Shendo"; $password = "*******"; $dbname = "exams"; // Create connection $conn = new mysqli_connect($servername, $username, $password, $dbname); // Check connection if (!$conn) { die(mysqli_error()); } else{ echo"connected!"; //---continue to do other things } ?>answered 3 years ago
Relevant content
- asked 10 months ago
- asked 8 months ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated a year ago