42

I installed xampp,but when I tried to run it I got an error as thus:

Error

MySQL said: Documentation

1045 - Access denied for user 'root'@'localhost' (using password: NO)

Connection for controluser as defined in your configuration failed. 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.

I tried to search on internet for a solution, but I still can't fix my problem. I have already checked whether I used a password or not in config.inc.php file but i have not used any password.Also, when i try to access with a password, I still can't solve this problem.

I hope anyone can help me. .thank you

Community
  • 1
  • 1
Saya Antisosial
  • 421
  • 1
  • 4
  • 4

20 Answers20

79

I had this problem after changing the password for the root user in phpMyAdmin. I know nothing about programming but I solved it by doing the following:

  1. Go to file C:\wamp\apps\phpmyadmin3.2.0.1\config.inc.php (I guess you would replace "wamp" with the name of your server if you're not using Wamp Server)

  2. Find the line $cfg['Servers'][$i]['password']='' and change this to

    $cfg['Servers'][$i]['password']='NO'
    
  3. Try opening phpMyAdmin again, and hopefully the message will now read "Access denied for user 'root'@'localhost' (using password: YES)

  4. Now change the password in the above line to 'yourpassword' (whatever you had set it to before)

Hope this helps somebody.

j0k
  • 21,914
  • 28
  • 75
  • 84
supernewbie
  • 799
  • 5
  • 3
  • 2
    The line `$cfg['Servers'][$i]['password']=''` does not even exist in my `config.inc.php`. Edit: Nevermind, i opened the wrong config.inc.php, there are multiple ones. – Black Oct 13 '15 at 08:57
  • I entered my password instead of 'NO' – david Oct 17 '18 at 23:26
  • 2
    Just to anyone confused. Now change the password in the above line to 'yourpassword' does not mean change ['password'] that to your password. Which is what I tried, it means change the NO to your password. – Lain Oct 24 '18 at 15:32
17

Go to the file C:\wamp\apps\phpmyadmin3.2.0.1\config.inc.php

Find the line $cfg['Servers'][$i]['password']='' and change it to

$cfg['Servers'][$i]['password']='root'

where root is the name of the password you had set in this instance

Hope this helps somebody.

Tito Amoo
  • 293
  • 2
  • 14
Sifudu Peter
  • 179
  • 1
  • 2
15

Step one: Go to... C:\xampp\phpMyAdmin

Step Two: Open the config.inc.php file

Step Three: Locate the following information and change the password.

/* Authentication type and info */
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'ENTER_YOUR_USER_NAME_HERE';
$cfg['Servers'][$i]['password'] = 'ENTER_YOUR_PASS_HERE';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['AllowNoPassword'] = true;
$cfg['Lang'] = '';
Ashutosh Sharma
  • 405
  • 1
  • 8
  • 19
13

Try this:

  1. Open config.inc.php file in the phpmyadmin directory
  2. Find line 21: $cfg['Servers'][$i]['password'] = '';
  3. Change it to: $cfg['Servers'][$i]['password'] = 'your_password';
  4. Restart XAMPP

Reference

Anbuselvan Rocky
  • 460
  • 4
  • 14
Himanshu Bhandari
  • 1,379
  • 1
  • 20
  • 32
9

Here's the solution to getting the 1045 Access denied for user 'root'@'localhost' (using password: NO) in phpMyAdmin.

First here's what happens:

The problem occurs when you change over from using phpMyAdmin with no password and mysql with no root password. You change root in mysql to having a root password. You dutifully change phpMyAdmin's config.ini.php file's $cfg['Servers'][$i]['password']='' line to include your password and restart everything you can find, but phpMyAdmin still can't get through.

The reason is that your browser still contains cookies for phpMyAdmin and those cookies reflect not needing a password to access mysql.

The solution:

Clear out the cookies relating to phpMyAdmin. Its browser specific, but in my Firefox, its under Tools > Page Info > Cookies.

You might need to relog in with phpMyAdmin or use the signon.php script (under /examples in my WAMP install).

Charlie
  • 10,054
  • 17
  • 74
  • 133
Mark Kasson
  • 1,492
  • 15
  • 24
3

Try this:

1. xampp/htdocs/xampp/cds.php

change line 4 to: mysql_connect("localhost","root","enter password here");
change line 64 to: if(!mysql_connect("localhost","root","enter password here"))

From here

Daniel Magnusson
  • 8,951
  • 2
  • 36
  • 43
2

reset your mysql password on xampp security page. restart your mysql service and then access the phpmyadmin page using your password. i tried it. this is working fine for me.

Jaydipsinh
  • 491
  • 1
  • 7
  • 27
  • Perfect! This worked for me. Go to the xampp security page http://http://localhost/security/index.php and click http://localhost/security/xamppsecurity.php, then change your password to something else. Then, restart MySQL and access the phpmyadmin page using your password. – hexicle Aug 17 '13 at 11:16
2

I'm using Linux Mint 18.2 of this writing. I had a similar issue; when trying to load myphpadmin, it said: "1045 - Access denied for user 'root'@'localhost' (using password: NO)"

I found the file in the /opt/lampp/phpmyadmin directory. I opened the config.inc.php file with my text editor and typed in the correct password. Saved it, and launched it successfully. Profit!

I was having problems with modifying folders and files, I had to change permission to access all my files in /opt/lampp/ directory. I hope this helps someone in the future.

mjk
  • 2,345
  • 4
  • 31
  • 31
David Soto
  • 31
  • 5
1

I'm afraid there's a conflict with the port number(80). Make sure you don't run some software like Skype that use the same port 80

Tepken Vannkorn
  • 9,380
  • 14
  • 55
  • 84
1

I think to troubleshoot your problem you should try the following:

  1. Check whether the MySQL service is running (Control Panel --> services)
  2. Use a MySQL client like SQLYOG to check whether you are able to connect to MYSQL Server with the username and password you are using in your code.
  3. Just try a sample php program, which fetches the data from table Ex. http://www.anyexample.com/programming/php/php_mysql_example__display_table_as_html.xml
Stu Pegg
  • 1,267
  • 1
  • 14
  • 39
Rahul Agrawal
  • 8,583
  • 16
  • 42
  • 59
1

My.ini from the file #password and #bind-address="127.0.0.1" are commented change the password to root and uncomment bind-address="127.0.0.1" and from the file cds.php change the

mysql_connect("localhost", "root", ""); to
mysql_connect("localhost", "root", "root");

Stop the Mysql services and try login again it got logged in.

Emad
  • 455
  • 5
  • 9
Mohanraj
  • 27
  • 2
1

1045 - Access denied for user 'root'@'localhost' (using password: NO) solution: Step 1: Open Location of you wamp/xampp Step 2: Go to phpmyadmin Step 3: Open config.inc.php Step 4: Change the password to the password set for the MySql server and not anything else in this: $cfg['Servers'][$i]['password'] = '' Step 5: Restart all services /restart wamp/xampp.

Capcha
  • 77
  • 1
  • 6
1

I had this problem with a fresh install of wamp and using only default settings without setting any passwords. I found an incorrect default setting and I solved it by the following steps:

  1. Go to C:\wamp\apps\phpmyadmin4.1.14 (Your phpmyadmin version# may differ)
  2. open the file config.inc in a text editor
  3. find the line: $cfg['Servers'][$i]['host'] = '127.0.0.1';
  4. change it to $cfg['Servers'][$i]['host'] = 'localhost';
  5. save the file
  6. restart all services in wamp

The problem seems to be that someone forgot to make the server and host match in the configuration files.

Tim Leon
  • 19
  • 3
  • really bad approach. use this only when you want to implement it locally. which is there's no point in doing this. you want XAMPP to access it from a different host in the first place. -1 from me – Foggy Minded Greenhorn Nov 09 '20 at 00:31
1

Try resetting your password since it seems it has changed you can reset your password by going to

C:\xampp\mysql

and clicking on the resetroot.bat file

Then change in the php config file the password back to blank and you should have access again

Lars Dormans
  • 159
  • 1
  • 11
1
  1. Open the config.inc.php file in the WAMP phpmyadmin directory

  2. Change the line ['Servers'][$i]['password'] = '' to

    $cfg['Servers'][$i]['password'] = 'your_mysql_root_password';

  3. Clear browser cookies

  4. Then Restart all services on WAMP

This worked for me.

NB: the password to use has to be the MySQL password.....

Rohit Poudel
  • 1,604
  • 2
  • 16
  • 19
y0ung0d
  • 43
  • 9
0

I had this same problem after I dropped the special PhpMyAdmin controluser account from MySQL.

I had to update the config.inc.php file and replace the entries for 'controluser' and controlpass' with 'user' and 'password'.

So my file ended like this:

$cfg['Servers'][$i]['user'] = 'root'; $cfg['Servers'][$i]['password']='123456';

timbo
  • 1
0

If you are using XAMPP rather than WAMP, the path you go to is:

C:\xampp\phpMyAdmin\config.inc.php
biniam
  • 7,518
  • 6
  • 42
  • 52
0

On OSX I had same difficult, but a figure out a solucition

open terminal

put 'cd /Applications/XAMPP/xamppfiles'
put 'sudo ./xampp security'

then put your root password and answer the questions

Ar No
  • 1,373
  • 17
  • 17
0

Check your MySQL Port number 3306.

Is there any other MySQL Install in your system on same port ?

If any installation found the change the port number to any number between 3301-3309 (except 3306)

user name : root
password : ' ' (Empty)

Rajiv Sharma
  • 5,330
  • 44
  • 44
-1
  1. try to go to Windows services and stop the MySQL service
  2. go to your wamp server and click on "restart all services".
  3. Refrsch your browser
Stephan Vierkant
  • 7,439
  • 6
  • 47
  • 79
rasdab
  • 1