[Solved] Warning: mysqli_connect(): (HY000/1045): Access denied for user ‘root’@’localhost’ (using password: NO) [duplicate]

PHP Warning: mysqli_connect(): (HY000/1045): Access denied for user
‘root’@’localhost’ (using password: NO) in
on line 8

$servername = "localhost";
$username = "root";
$password = "";
$dbname = "peace";

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

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

Enquirer: Zeshan


Solution #1:

Access denied means that the authentication failed. That means there is an invalid username or password combination. For SQL, it’s obvious that the user can be root. So please go to your phpMyAdmin and check from the users tab. You may find out the password set on the root account. And usually online databases are always password protected.

Respondent: Gideon Appoh

Solution #2:

the root password could be empty but the option selected is password. At the change password button in your admin, there’s a radio button with two option ( 1. No password and 2. Password) Most of the time the password option is selected therefore requires/assumes you have a password. Just get to the options and change to No password option.
Worked for me

Respondent: Collin Kiprono

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Most Popular

To Top
India and Pakistan’s steroid-soaked rhetoric over Kashmir will come back to haunt them both clenbuterol australia bossier man pleads guilty for leadership role in anabolic steriod distribution conspiracy