Phpmyadmin: mysqli::real_connect(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: YES)

Created on 10 Apr 2020  路  31Comments  路  Source: phpmyadmin/phpmyadmin

Describe the bug

I cannot log in to phpMyAdmin.

To Reproduce

Steps to reproduce the behavior:
Go to homepage
Login with a username of "root", and any password, even the one in the configuration.

Expected behavior

I expected myself to be logged into the PMA dashboard.

Screenshots

image

Server configuration

  • Operating system: Windows 10
  • Web server: Apache 2.4.41
  • Database version: 8.0.18
  • PHP version: 7.4.0
  • phpMyAdmin version: 5.0.2

Client configuration

  • Browser: Opera GX
  • Operating system: Windows 10

Additional context

None.

invalid question

Most helpful comment

I met the same mistake.After careful check, I found that the user and password of "phpstudy" database column are "root" and "root" instead of "123456". I don't know why, but the login succeeded, you can try it!

All 31 comments

Don't act confused, I'm trying to log in, but I can't because it thinks I'm using the wrong password. I'm using the same password in the config.inc.php file.

Hello @hiimjustin000
You are just using the wrong password ;)
How did you install the MySQL server ?

Installing WAMP. I am absolutely not using the wrong password. I double-checked and it is the same one in config.inc.php.

@hiimjustin000 To be sure everything is okay please try to connect using the mysql command line or a piece of code. After you can conclude the code or tool was able to connect we can discuss to find a _possible_ bug

Also could you send your configuration file?

Tried with a different user (hiimjustin000@localhost) and got the same error. I'm not using the wrong password!

okay, then maybe we should try to debug your config.inc.php file

<?php
/*
 * Generated configuration file
 * Generated by: phpMyAdmin 5.0.2 setup script
 * Date: Thu, 09 Apr 2020 21:52:51 +0000
 */

/* Servers configuration */
$i = 0;

/* Server: localhost [1] */
$i++;
$cfg['Servers'][$i]['verbose'] = '';
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['port'] = '';
$cfg['Servers'][$i]['socket'] = '';
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['user'] = 'hiimjustin000';
$cfg['Servers'][$i]['password'] = 'censored';
$cfg['Servers'][$i]['AllowNoPassword'] = true;

/* End of servers configuration */

$cfg['blowfish_secret'] = 'censored';
$cfg['DefaultLang'] = 'en';
$cfg['ServerDefault'] = 1;
$cfg['UploadDir'] = '';
$cfg['SaveDir'] = '';
?>

@hiimjustin000 you will have to reset the leaked passwords in the previous post because we receive notifications by email and they are archived.

Anyway $cfg['Servers'][$i]['auth_type'] = 'cookie'; should be $cfg['Servers'][$i]['auth_type'] = 'config'; to allow usage of user and password

Crap... Well ok then.

image

Hi,

You may already know this but just to be sure.

phpMyAdmin passes the username and password you provide along to MySQL. You don't define the password in config.inc.php that you wish to use when logging in, you must tell phpMyAdmin a valid MySQL user account. When you're using the auth_type 'cookie' (or 'http'), you are prompted for the username and password (the $cfg['Servers'][$i]['user'] and $cfg['Servers'][$i]['password'] directives aren't used). When using the 'config' authentication type, the values you provide for user and password must match an existing user in MySQL.

https://docs.phpmyadmin.net/en/latest/intro.html#a-word-about-users

image
hiimjustin000@localhost has the same password as mentioned in config.inc.

So using the command line you could login to the user ?
_Time to sleep :fr:_

Yes, I can.

How do I make it so when I put it to type "cookie", it will accept the config.inc values? WAMP people can do that, so I can.

The cookie mode does not use the user,password values, you are free to put the right or wrong credentials in the form

How do I make it so when I put it to type "cookie", it will accept the config.inc values?

That's not how 'cookie' authentication works, it doesn't read the 'user' and 'password' fields from config.inc.php because you're prompted for them when you connect. WAMP, at least last time I checked, uses the 'config' auth_type setting, which does use the 'user' and 'password' that are hardcoded in the configuration.

Your configuration looks okay to me, in particular the use of host 'localhost' matches with the hostname of the user that exists in the screenshot, which is a common problem people often encounter (trying to connect via '127.0.0.1' to an account with host field 'localhost').

We did recently make some changes to code that handled "special characters" in passwords, would you mind downloading an older version and seeing if you're able to connect successfully? Version 5.0.0 can be downloaded from https://www.phpmyadmin.net/files/5.0.0/

Somehow works now. Only my PHP code (Not in PHPMyAdmin) acts up now.

Website sends back Connection failed: SQLSTATE[HY000] [1045] Access denied for user 'hiimjustin000'@'localhost' (using password: YES)

I would definitely create another user with a simple name and password just to understand what is going wrong

I looked closely...

Maybe try what Isaac mentioned to use 127.0.0.1 instead of localhost

Didn't work.

127.0.0.1 Does not work. Still.

"Only my PHP code" where is it ?
on your local station ?

I mean this code written by Michael Brabec.

<?php
//error_reporting(0);
include dirname(__FILE__)."/../../config/connection.php";
@header('Content-Type: text/html; charset=utf-8');
try {
    $db = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password, array(
    PDO::ATTR_PERSISTENT => true
));
    // set the PDO error mode to exception
    $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    }
catch(PDOException $e)
    {
    echo "Connection failed: " . $e->getMessage();
    }

|C:/justingdps.com/server/incl/lib/connection.php|/../../config/connection.php exists

I am closing this issue because it does not seem to be a phpMyAdmin issue and also seems to be resolved.

mysqli::real_connect(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: YES)

use password "root"

I met the same mistake.After careful check, I found that the user and password of "phpstudy" database column are "root" and "root" instead of "123456". I don't know why, but the login succeeded, you can try it!

I met the same mistake.After careful check, I found that the user and password of "phpstudy" database column are "root" and "root" instead of "123456". I don't know why, but the login succeeded, you can try it!

Thanks for your answer

IMG_20210121_010759_299

Finally found the answer we all need...

Was this page helpful?
0 / 5 - 0 ratings