31

I am unable to connect to my MySQL in xampp I have this error:

MySQL said: Documentation

#1045 - Access denied for user 'root'@'localhost' (using password: NO) mysqli_real_connect(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: NO) phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection. You should check the host, username and password in your configuration and make sure that they correspond to the information given by the administrator of the MySQL server.

CONFIG.INC.PHP file

<?php
/*
* This is needed for cookie based authentication to encrypt password in
* cookie
*/
$cfg['blowfish_secret'] = 'xampp'; /* YOU SHOULD CHANGE THIS FOR A MORE SECURE COOKIE AUTH! */

/*
* Servers configuration
*/
$i = 0;

/*
* First server
*/
$i++;

/* Authentication type and info */
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = '';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['AllowNoPassword'] = true;
$cfg['Lang'] = '';

/* Bind to the localhost ipv4 address and tcp */
$cfg['Servers'][$i]['host'] = '127.0.0.1';
$cfg['Servers'][$i]['connect_type'] = 'tcp';

/* User for advanced features */
$cfg['Servers'][$i]['controluser'] = 'pma';
$cfg['Servers'][$i]['controlpass'] = '';

/* Advanced phpMyAdmin features */
$cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';
$cfg['Servers'][$i]['bookmarktable'] = 'pma__bookmark';
$cfg['Servers'][$i]['relation'] = 'pma__relation';
$cfg['Servers'][$i]['table_info'] = 'pma__table_info';
$cfg['Servers'][$i]['table_coords'] = 'pma__table_coords';
$cfg['Servers'][$i]['pdf_pages'] = 'pma__pdf_pages';
$cfg['Servers'][$i]['column_info'] = 'pma__column_info';
$cfg['Servers'][$i]['history'] = 'pma__history';
$cfg['Servers'][$i]['designer_coords'] = 'pma__designer_coords';
$cfg['Servers'][$i]['tracking'] = 'pma__tracking';
$cfg['Servers'][$i]['userconfig'] = 'pma__userconfig';
$cfg['Servers'][$i]['recent'] = 'pma__recent';
$cfg['Servers'][$i]['table_uiprefs'] = 'pma__table_uiprefs';
$cfg['Servers'][$i]['users'] = 'pma__users';
$cfg['Servers'][$i]['usergroups'] = 'pma__usergroups';
$cfg['Servers'][$i]['navigationhiding'] = 'pma__navigationhiding';
$cfg['Servers'][$i]['savedsearches'] = 'pma__savedsearches';
$cfg['Servers'][$i]['central_columns'] = 'pma__central_columns';
$cfg['Servers'][$i]['designer_settings'] = 'pma__designer_settings';
$cfg['Servers'][$i]['export_templates'] = 'pma__export_templates';
$cfg['Servers'][$i]['favorite'] = 'pma__favorite';

/*
 * End of servers configuration
 */

?>

17 Answers 17

42

found a solution, in my config file I just changed

$cfg['Servers'][$i]['auth_type'] = 'config';

to

$cfg['Servers'][$i]['auth_type'] = 'HTTP';
Sign up to request clarification or add additional context in comments.

1 Comment

this worked for me. Why should we choose HTTP but not config?
18
/* Authentication type and info */
$cfg['Servers'][$i]['password'] = '';<----your password

or

/* User for advanced features */

$cfg['Servers'][$i]['controluser'] = 'pma';

$cfg['Servers'][$i]['controlpass'] = '';

to

/* User for advanced features */

$cfg['Servers'][$i]['controluser'] = 'your user';

$cfg['Servers'][$i]['controlpass'] = 'your password';

Comments

12

You may have set different passwords for user 'root' or have been changed your password. I had the same error as:

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

and I found that my root password for PHPMyAdmin is not the same on both 'mysql' and 'phpmyadmin' databases, so I updated my password for 'phpmyadmin' database same as 'mysql' database as follow:

sudo gedit /etc/phpmyadmin/config-db.php

and update the fields

$dbuser='root';

$dbpass='myNewPassword'; <-- update your new password here

2 Comments

The answer for my problem is to fix privilege granted user information instead of 'root' as @Farhikhteh told
This solved my issue! for some strange reason the username and password set by default was not overwritten on installation, going to the config-db.php file led me to my issue! You saved me !
9

Change the value of

$cfg['Servers'][$i]['user'] = 'groot';
$cfg['Servers'][$i]['password']='groot';

in your ~/xampp/phpMyAdmin/config.inc.php

Here my username is groot and password is groot.

Comments

7

It happened with me before: go to path for windows

C:\xampp\phpMyAdmin\

go to path for linux:

/etc/phpmyadmin/

found file name is :
config.inc.php open file
change this:

['password'] = ''

to:

['password'] = 'root'

this default
It might be any password if you changed it from the control panel

Comments

4

Edit the file xampp/mysql/bin/my.ini

Add

skip-grant-tables

under [mysqld]

3 Comments

Its very dangerous: "When MySQL is started with this parameter, it completely avoids checking its grant tables upon connection and upon query. This means anyone can log in from anywhere, and do anything on the database." code.openark.org/blog/mysql/dangers-of-skip-grant-tables
later you grant that using mysql query and then turn of skip-grants a quick workaround
Downvote: it's a bad idea to do that. You should reset the root password (search stackoverflow, there's tons of posts on that) or create an appropriate user, grant te appropriate permissions and configure you config.inc.php
4

Follow these steps- 1.go to config.inc.php file and find - $cfg['Servers'][$i]['auth_type']

2.change the value of $cfg['Servers'][$i]['auth_type'] to 'cookie' or 'http'.

3.find $cfg['Servers'][$i]['AllowNoPassword'] and change it's value to true.

Now whenever you want to login, enter root as your username,skip the password and go ahead pressing the submit button..

Note- if you choose authentication type as cookie then whenever you will close the browser and reopen it ,again you have to login.

3 Comments

I have set this but at time of login I am fetching this error "Failed to set session cookie. Maybe you are using HTTP instead of HTTPS to access phpMyAdmin."
@BhavinThummar is it working when you are using incognito mode??
Weird that this one is not the accepted answer, it is the most simpler and logical. With this setup (though I prefer AllowNoPassword to false) you will get prompted by the native phpMyAdmin login form. With this method, it becomes just matter of changing the auth_type to cookie . Obviously, from command prompt, you will use mysqladmin -u root password to set your own new secure password
4

You need to modify the config-db.php and set your password to the password you gave to the user root, or else if he has no password leave as this ''.

1 Comment

Please use the code formatting for e.g. adding config-db.php in code formatting as config-db.php. Do the same thing with value such as 'root' and ''. Also it will be very helpful if you could copy paste the part of file, along with location. Make sure, while pasting, you remove your private information such as credentials.
3
$cfg['Servers'][$i]['auth_type'] = 'HTTP';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = '1234';

This solves my problem too. It just logs in automatically.

1 Comment

HTTP login opens the popup but the login is not working.
2

This is the Different Solution, Check if your Services are running correctly, if WAMP icon showing orange color, and 2 out of 3 services are running it's showing, then this solution will work . Root cause:

If in your system mysql was there, later you installed WAMP then again one MYSQL will install as WAMP package, default port for MYSQL is 3306 , So in both mysql the port will be 3306, which is a port conflict, So just change the port it will work fine. Steps to change the Port.

  1. Right click the WAMP icon.
  2. Chose Tool
  3. Change the port in Port used by MySql Section

Comments

2

If you are using macbookpro and getting this error on XAMPP then you also need to change the permission of file config.inc.php. Sorry I was first time user of xampp on macbook pro and was not knowing its directory structure and other details so adding this answer for first time users.

From XAMPP interface click to 'go to Terminal' and from there use below commands

       root@debian: cd /opt/lampp/phpmyadmin

inside this directory you will find the config.inc.php Now use chmod 777 config.inc.php, please note that you need to make it writable you can use equivalent code instead of 777. I used 777 for me.

       root@debian: chmod 777 config.inc.php

Now open the file from explorer or network drive to any editor make the below changes -

  1. search for 'Authentication type' in file, you will find it in comment

  2. below this comment you will find

     $cfg['Servers'][$i]['auth_type'] = 'config';
     $cfg['Servers'][$i]['user'] = 'root';
     $cfg['Servers'][$i]['password'] = 'here_you_need_to_type_your_root_password';
    
  3. now it still didnot work for me after this step, it was complaining about config file permission so I had to revert back the permission back to -rw-r--r-

       root@debian: chmod 644 config.inc.php
    

and then it worked fine.

Comments

1

In case none of the aforementioned solutions works for you, then simply do the under changes. Change this

$cfg['Servers'][$i]['host'] = '127.0.0.1';

to

$cfg['Servers'][$i]['host'] = 'localhost';

and

$cfg['Servers'][$i]['auth_type'] = 'config';

to

$cfg['Servers'][$I]['auth_type'] ='cookies';

It works in my situation, possibly works on your situation also.

Comments

1

Go got XAMPP->mysql->bin->my.ini

open the file with an editor and add 'skip-grant-tables' after mysql.

Comments

0

Just do what the message is asking for, create the user pma@localhost in the phpMyAdmin panel with no password

Comments

0

Check /etc/phpmyadmin/config-db.php file

  1. Go to terminal
  2. run vi /etc/phpmyadmin/config-db.php
  3. check the information
  4. Hit Ctrl + X
  5. Try login to phpmyadmin again through the web using the information from the config file.

Comments

0

Please run and re reconfigure your phpmyadmin

sudo dpkg-reconfigure phpmyadmin

Comments

0

When you install the WAMPP in your machine by default the password of PhpMyAdmin is blank. so put root in user Section and left blank of password field. hope it works.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.