What could be causing the "Access Denied" error when accessing the database on the web server?

The "Access Denied" error when accessing the database on the web server could be caused by incorrect database credentials, insufficient permissions for the user to access the database, or a misconfiguration in the database connection settings. To solve this issue, make sure that the database credentials in your PHP code are correct, the user has the necessary permissions to access the database, and the connection settings are accurate.

<?php
$servername = "localhost";
$username = "your_username";
$password = "your_password";
$dbname = "your_database";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
?>