Skip to content
PHP Logo

What is the common cause of the phpmyadmin error 1045 related to access denied for user 'root'@'localhost'?

The common cause of the phpmyadmin error 1045 related to access denied for user 'root'@'localhost' is incorrect credentials being used to access the MySQL database. This error typically occurs when the password for the 'root' user is incorrect or has been changed. To solve this issue, you can reset the password for the 'root' user in MySQL.

php
<?php
$servername = "localhost";
$username = "root";
$password = ""; // Enter your new password here
$dbname = "your_database_name";

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

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

echo "Connected successfully";
?>