-2

I hope this question falls within the scope of this site. I have created a Lightsail instance in AWS and added a MYSQL database to it. I have been able to connect to the database with Workbench, but not with a PHP file hosted in my instance.

I have checked the servername, username, password and dbname 20 times. Every time I try to connect I get the error message: "Connection failed 6: Unknown database 'Databasename-1'". Does anybody know of a guide on troubleshooting connecting to a MYSQL database on Lightsail?

<?php
$servername = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.rds.amazonaws.com";
$username = "xxxxxx";
$password = "xxxxxx";
$dbname = "Databasename-1";

$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
  die("Connection failed 6: " . $conn->connect_error);
}
turkeyhundt
  • 214
  • 1
  • 15
  • Have you setup the appropriate inbound rules on your RDS instance? To confirm you have good connectivity you can run `mysql -h -P 3306 -u -p` from your instance. – Tim Dec 15 '22 at 18:46
  • OK @Tim I did try that from my SSH connection and was able to run that. That revealed that the name at the top of the web page for the database in my lightsail account was not, in fact, the name of a database. While I'm not sure how to view this info through the interface, this is a big step for me. Thank you for the assistance. – turkeyhundt Dec 15 '22 at 19:03

1 Answers1

-1

So, i think it turns out I did not know how to get the database name from my lightsail instance and possibly not understand how to use Workbench. I was using a database name that did not exist.

I just started over and created everything from scratch from the command prompt and everything works as expected.

turkeyhundt
  • 214
  • 1
  • 15