Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

phpMyAdmin is throwing a #2002 cannot log in to the mysql server phpmyadmin

I have installed MySQL server enterprise 5.1 on my local machine and now I want to install phpMyAdmin, but it does not work.

I have unrared phpMyAdmin to my server root directory and browsed to "localhost/phpMyAdmin/setup/index.php", started a new server and the only setting I changed was filling in my MySQL password in the field "Password for config auth"

So now when I am trying to log in I get an error message saying "#2002 cannot log in to the mysql server phpmyadmin"

Does anyone know what's wrong? I've been having this problem since yesterday.

like image 648
narancha Avatar asked Sep 12 '10 11:09

narancha


People also ask

Why is my localhost phpMyAdmin not working?

I solved this problem by changing the proxy of my firefox browser, go to menu tools-Option find tab Network, click button settings. Fill the text box below No Proxy for with localhost. Then press Ok, then Ok again. Try now typing localhost/xampp then it should show Welcome to XAMPP for Windows!

What is GREY key in phpMyAdmin?

'not able to insert data' - then you are violating a unique key - but you don't say what you are trying to do, what do do if a duplicate is encountered and have not provided sample data and expected output.


3 Answers

If you're getting the #2002 Cannot log in to the MySQL server error while logging in to phpmyadmin, try editing phpmyadmin/config.inc.php and change:

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

to:

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

Solution from Ryan's blog

Edit (20-Mar-2015):

Note that if you're on a fresh install, config.inc.php may not exist. You need to rename / copy config.sample.inc.php and then change the relevant line

like image 158
kouton Avatar answered Oct 05 '22 15:10

kouton


This is old but as it is the first result in Google,

Please note that this also happens when your MySql service is down,

I fixed this by simply restarting MySQL Server using:

/etc/init.d/mysql restart

in SSH (Command is for a CentOS/CPanel server)

like image 26
Vladimir Avatar answered Oct 05 '22 16:10

Vladimir


Background: I am using Linux Mint 13. In my case, this error happened when I restarted the computer and my DHCP assigned a new local IP address (from 192.168.0.2 to 192.168.0.4) to my desktop.

sudo gedit /etc/mysql/my.cnf

Update

bind-address = 192.168.0.2

to

bind-address = localhost

This fixed the problem. Enjoy.

like image 9
Knight Avatar answered Oct 05 '22 16:10

Knight