What are some potential reasons for a "Access denied" error when using mysql_connect?

The "Access denied" error in MySQL can occur due to incorrect username, password, or host information provided in the mysql_connect function. To solve this issue, double-check the credentials being used to connect to the MySQL database and ensure they are correct. Additionally, make sure the user has the necessary permissions to access the database.

$servername = "localhost";
$username = "your_username";
$password = "your_password";
$database = "your_database";

// Create connection
$conn = mysqli_connect($servername, $username, $password, $database);

// Check connection
if (!$conn) {
    die("Connection failed: " . mysqli_connect_error());
}
echo "Connected successfully";