What could be causing the "Access denied for user" error in the MySQL connection?

The "Access denied for user" error in MySQL connection is typically caused by incorrect credentials such as an incorrect username, password, or hostname. To resolve this issue, double-check the username, password, and hostname in your connection settings to ensure they are correct.

<?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";
?>