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.
asked Sep 12, 2010 at 11:02
4
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
answered Apr 17, 2013 at 13:37
koutonkouton
1,9412 gold badges19 silver badges34 bronze badges
5
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)
answered May 20, 2015 at 14:29
VladimirVladimir
1,6022 gold badges18 silver badges40 bronze badges
0
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.
Zenexer
18.6k9 gold badges70 silver badges77 bronze badges
answered Dec 29, 2013 at 16:36
KnightKnight
931 silver badge4 bronze badges
2
This can also be caused if you forget (as I did) to move config.inc.php into its proper place after completing the setup script.
After making the config folder and doing chmod o+rw config and going to localhost/phpmyadmin/setup and following those steps, you need to go back to the command line and finish things off:
mv config/config.inc.php . # move file to current directory
chmod o-rw config.inc.php # remove world read and write permissions
rm -rf config # remove not needed directory
See full instructions at https://phpmyadmin.readthedocs.org/en/latest/setup.html
answered Nov 16, 2013 at 18:36
Geoffrey BoothGeoffrey Booth
7,1005 gold badges35 silver badges41 bronze badges
1
After trying all of the above suggestions here is what fixed my #2002 error.
Add the following line to your config.inc.php file and change the number to your MySQL port:
$cfg['Servers'][$i]['port'] = '3307'; // MySQL port
I had multiple mysql instances installed, and in this case, I had updated my.ini to run MySQL on port 3307, but had not updated phpMyAdmin to reflect the new port. In my case, the line for the port did not exist in the config.inc.php file, so I was not aware that it needed updating.
answered May 5, 2014 at 16:06
Did you set up the MySQL on your machine? It sounds like you’re using Windows; MySQL runs as a «Service» on your machine (right-click My Computer -> Manage -> Services).
answered Sep 12, 2010 at 11:07
amphetamachineamphetamachine
27.2k12 gold badges60 silver badges72 bronze badges
1
I’ve been through basically all of stackoverflow for this error and nothing resolved my issue. I was able to log into mysql directly from the linux command line fine, but with the same user and password couldn’t log into phpmyadmin.
So I beat my head against the wall for half the day until I realized it wasn’t even reading the config.inc.php under /etc/phpmyadmin (the only place it was located btw based on «find / -iname config.inc.php». So I changed the host in /usr/share/phpMyAdmin/libraries/config.default.php and it finally worked.
I know there’s probably another issue with why it isn’t reading the config from the /etc/phpmyadmin folder but I can’t be bothered with that for now 
tldr; if your settings don’t seem to be applying at all try making the changes within /usr/share/phpMyAdmin/libraries/config.default.php
answered Feb 20, 2015 at 18:03
1
I have also experienced the same thing, hopefully a this helps.
cd /etc/init.d
./mysql start
please login to access mysql and phpmyadmin
Rohit Gupta
4,01219 gold badges31 silver badges41 bronze badges
answered Oct 21, 2015 at 1:04
0
It happened with me when I changed the instance type of my AWS server.
#2002 Cannot log in to the MySQL server can also occur when the mysqld service is not started.
So first of all you need to execute :
$ sudo service mysqld restart
This will give you :
$ sudo service mysqld restart
Stopping mysqld: [ OK ]
Starting mysqld: [ OK ]
After that the error will not come.
P.S. On EC2 instances, one should also change the host from localhost to 127.0.0.1 as mentioned in the top answer.
answered Jun 15, 2016 at 20:43
driftking9987driftking9987
1,6731 gold badge32 silver badges63 bronze badges
- Right-click My Computer -> Manage -> Services
- Choose «Services» under the «Services and Application» from right pane
- Then search for the «Zend Development» Service.
- When you find it, double click to start that service.
Now, you should be able log in to phpMyAdmin.
pjmorse
9,1749 gold badges54 silver badges124 bronze badges
answered Sep 8, 2012 at 6:45
1
I had same issue after the server has been attacked using a DDoS (actually a penetration testing tool).
I’ve headed to /etc/var/mysql/error.log first to see the InnoDB had a file lock.
The issue was immediately fixed by restarting the server, however that’s not future-proof.
answered Jan 30, 2014 at 16:30
igraczechigraczech
2,3883 gold badges25 silver badges30 bronze badges
In my system, config.inc.php didn’t exist, but config.sample.inc.php existed. Try copying the sample script to config.inc.php
answered Jun 22, 2016 at 9:12
Had this problem a number of times on our setup, so I’ve made a check list.
This assumes you want phpMyAdmin connecting locally to MySQL using a UNIX socket rather than TCP/IP.
UNIX sockets should be slightly faster as they have less overhead and can be more secure as they can only be accessed locally.
Service
- Is the mysqld service running?
service mysqld status - .. If not
service mysqld start - Has config has changed since service started?
service mysqld restart
MySQL Config (my.cnf)
- Check that there isn’t a non-socket client protocol set, e.g.
protocol=tcp - Check that the socket location is accessible and has the right permissions
PHP Config (php.ini)
If you can connect locally from the command line, but not from phpMyAdmin, and the socket file is not in the default location:
- Set the mysqli default sockets to the new location:
mysqli.default_socket = *location* - … I also set the
pdo_myql.default_socketandmysql.default_socketjust to be sure - Restart your web service (httpd in my case)
service httpd restart
phpMyAdmin Config (config.inc.php)
- Check that the host is set to localhost:
$cfg['Servers'][$i]['host'] = 'localhost'; - The socket location can also be set here:
$cfg['Servers'][$i]['socket'] = '*location*';
N.B.
As pointed out by @chk; Setting the $cfg['Servers'][$i]['host'] from localhost to 127.0.0.1 just causes the connection to use TCP/IP rather than using the socket and is more of a workaround than a solution.
The MySQL config setting bind-address= also only affects TCP/IP connections.
If you don’t need remote connections, it is recommended to turn off TCP/IP listening with skip-networking.
answered Feb 14, 2017 at 13:05
ArthArth
12.7k5 gold badges37 silver badges69 bronze badges
For Ubuntu 14.04 and 16.04, you can apply following commands
First, check MySQL service is running or not using
sudo service mysql status
Now you can see you show a message like this: mysql stop/waiting.
Now apply command: sudo service mysql restart!
Now you can see you show a message like this: mysql start/running, process 8313.
Now go to the browser and logged in as root(username) and root(password) and you will be logged in successfully
answered Jan 5, 2019 at 8:10
In ubuntu OS in ‘/etc/php5/apache2/php.ini’ file do configurations that this page said.
answered Mar 11, 2013 at 17:13
RahaRaha
291 gold badge1 silver badge6 bronze badges
0
For those who get this error when working with WAMP/XAMP on a windows machine.
This may help you.
Your solution is to
- net stop mysql
- Erase binary logs (and the binary log index file)
- IF you do not know where they are, locate my.ini on your PC
- Open my.ini in Notepad look for the option log-bin or log_bin
- Look for the option datadir
- If log-bin only has a filename, look inside the folder specified by datadir
- If log-bin includes a path and a filename, look inside the folder specified by log-bin
- Open the desired folder in Windows Explorer
- Remove the binary logs There should be a file whose
file extension is .index. Delete this as well net start mysql
Please DO NOT ERASE ib_logfile0 or ib_logfile1 when you have binary log issues.
Answer is on dba.stackexchange
answered Feb 16, 2014 at 23:41
heyomiheyomi
3854 silver badges18 bronze badges
CAUTION: This method completely removes MySQL data!
I have same problem in Ubuntu 12.10 , mysql 5.5
I have tested lots of answer related to my issue but none of theme work
at last I had to reinstall remove my mysql server completely and then I install again Mysql server
but you should be aware that you should delete all directory which related to Mysql
I use this link to remove mysql completely
sudo apt-get remove --purge mysql-server mysql-client mysql-common
sudo apt-get autoremove
sudo apt-get autoclean
sudo deluser mysql
sudo rm -rf /var/lib/mysql
sudo rm -rf /etc/mysql
sudo rm -rf /var/lib/mysql
sudo rm -rf /var/run/mysqld
and then you install again LAMP by tasksel
Removing MySQL 5.5 Completely
https://serverfault.com/questions/254629/unable-to-install-mysql-server-in-ubuntu/296928#296928
answered Feb 5, 2014 at 13:45
masoud2011masoud2011
8649 silver badges8 bronze badges
After Many attempts in getting this fixed, it was found out that the issue was with Mysql users not being allowed to login
netstat -na | grep -i 3306
If it is listening on all interfaces, then you can assign any of your interfaces to this
$cfg['Servers'][$i]['host'] = 'ANY INTERFACE';
Try to Login using the above IP using the comand line
mysql -u bla -p -h <Above_IP_address>
If this works then your phpmyadmin will also work, If not fix the mysql.user table so that the above command works and allows you to login to mysql.
answered May 5, 2014 at 12:14
Right-click My Computer -> Manage -> Services
Choose «Services» under the «Services and Application» from right pane
Then search for the «mysql» Service.
When you find it, double click to start that service.
Now you should be able to run and login to PhpMyAdmin
answered Sep 3, 2014 at 13:05
Masivuye CokileMasivuye Cokile
4,7543 gold badges19 silver badges34 bronze badges
Check whether you server is running or not.
answered Oct 1, 2014 at 10:53
It is because your system has two installations of «mysql» packages. One installation was made through xampp/lampp and another installation was made through mysql-debain package. To solve the problem, just go to «synaptic manager» and remove mysql, and then you will be able to access mysql from xampp server.
Note : removing mysql from synaptic manager doesn’t affect mysql which was installed through xampp/lampp server. So don’t worry!
answered Jul 3, 2015 at 13:30
Just in case anyone has anymore troubles, this is a pretty sure fix.
check your etc/hosts file make sure you have a root user for every host.
i.e.
127.0.0.1 home.dev
localhost home.dev
Therefore I will have 2 or more users as root for mysql:
root@localhost
root@home.dev
this is how I fixed my problem.
Rohit Gupta
4,01219 gold badges31 silver badges41 bronze badges
answered Oct 10, 2014 at 20:47
Victor BojicaVictor Bojica
3331 gold badge4 silver badges14 bronze badges
For me the problem was solved by deleting a .pid file named after my computer:
sudo rm /var/mysql/computername.pid
answered Feb 7, 2016 at 13:16
This the following line in your php.ini file
mysql.default_socket = "MySQL"
to
mysql.default_socket = /var/run/mysqld/mysqld.sock
answered Jul 25, 2016 at 4:04
This problem occurs when you already had MySQL installed on your machine or in case you have changed the post number of the MySql service which is 3306(Default). In order to solve this, you have to tell the phpMyAdmin to look for another port instead of 3306. To do so go to C:xamppphpMyAdmin(default location) and open Config.inc and add this line $cfg['Servers'][$i]['port'] = '3307'; after $cfg['Servers'][$i]['AllowNoPassword'] = true; Restart the services and now it should work.
Francisco
10.8k6 gold badges34 silver badges45 bronze badges
answered Jun 21, 2017 at 7:32
I had an issue with the path of the MySQL service in the Windows 7 registry
which was not changed with the new installed XAMPP or newer easyPHP
version.
So if anybody has the same problem (#2002 error, phpMyAdmin cannot be
started) you can search into the win regedit for ‘my.ini’ and exchange the
path to the new package.
For example I exchanged on a few places the older path:
C:EASYPH~1.1VCbinariesmysqlbineds-mysqld.exe
—defaults-file=C:EASYPH~1.1VCbinariesmysqlmy.ini MySQL
with the newer one:
c:xamppmysqlbinmysqld.exe —defaults-file=c:xamppmysqlbinmy.ini
mysql
It is strange that nobody described this issue before on the web!
Francisco
10.8k6 gold badges34 silver badges45 bronze badges
answered Feb 9, 2015 at 11:34
my problem is solved by this step
- apt-get install mysql-server phpmy admin
- /etc/init.d/mysql restart
- done.
answered Aug 31, 2018 at 18:24
Can’t access your MySQL server via phpMyAdmin due to error 2002?
A MySQL service restart or configuration correction can let you access the MySQL server.
At Bobcares, we often get requests to fix phpMyAdmin errors, as a part of our Server Management Services.
Today, let’s see how our Support Engineers fix this error.
What is phpMyAdmin error 2002?
phpMyAdmin is a tool to manage MySQL database via a front panel. This tool makes database management easier with the user interface.
But what if you can’t even access it? The typical error message while a user tries to access it appears as:
phpMyAdmin error 2002 is a common error when a new user is accessing it. Because of the newly setup configuration is not proper. It needs some corrections. Otherwise, the MySQL server is not working,
Our Experts in Server Administration always fix this error for our customers. Let’s see how we do it.
How we fix phpMyAdmin error 2002?
Customers often approach us with the error message ‘2002 Cannot log in to the MySQL server‘. Let us discuss how our Support Engineers resolve the error for our customers.
1. If MySQL server is down
In this case, our Support Team first checks if the MySQL server is functioning properly. If not we restart the service.
For a CentOS server, we use the command,
/etc/init.d/mysql restart
In most cases this fixes the error.
2. Improper configuration
If the server is up, next our Support Engineers check the configuration file.
By default, phpmyadmin/config.sample.inc.php is the configuration file. We make a copy of this file in the name phpmyadmin/config.inc.php.
This file holds the configuration needed for phpMyAdmin to function.
We check for entries that mostly lead to error. That is,
$cfg['Servers'][$i]['host'] = 'localhost';
This indicates the server host. We change this to localhost IP (127.0.0.1).
$cfg['Servers'][$i]['host'] = '127.0.0.1';
Now we try to connect to phpMyAdmin. If the error still persist we make changes to the other parameters as well.
Another parameter is the connection type, which we set it accordingly. Here it is set to tcp.
$cfg['Servers'][$i]['connect_type'] = 'tcp';
In case of socket connection the required changes are:
$cfg['Servers'][$i]['socket'] = 'location of socket file';
$cfg['Servers'][$i]['connect_type'] = 'socket';
Hence we ensure to fix the error.
[Need assistance in fixing phpMyAdmin errors? – We’ll help you.]
Conclusion
In short, phpMyAdmin error 2002 occurs when the user tries to access it. This error indicates that either the MySQL server is down or the phpMyAdmin has a bad configuration. Today, we saw how our Support Engineers fix this error.
PREVENT YOUR SERVER FROM CRASHING!
Never again lose customers to poor server speed! Let us help you.
Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.
GET STARTED
var google_conversion_label = «owonCMyG5nEQ0aD71QM»;
I have been through lots of forums and checked various posts on similar topic but non seems to work out for me.
I have freshly installed XAMPP 1.7.7 on my Ubuntu 11.10 Operating system. Everything is running except for the phpMyAdmin.
Upon hitting: http://localhost/phpmyadmin, I am getting the following error:
MySQL said:
#2002 - The server is not responding (or the local MySQL server's socket is not correctly configured) Connection for controluser as defined in your configuration failed.
When i am starting the services with: sudo /opt/lampp/lampp start
I am getting the following:
XAMPP: Another web server daemon is already running.
XAMPP: Another MySQL daemon is already running.
XAMPP: Another FTP daemon is already running.
XAMPP for Linux
started.
Any suggestions would be greatly appreciated.
asked May 3, 2012 at 6:52
CompilingCyborgCompilingCyborg
4,75013 gold badges44 silver badges61 bronze badges
2
It turns out that the solution is to stop all the related services and solve the “Another daemon is already running” issue.
The commands i used to solve the issue are as follows:
sudo /opt/lampp/lampp stop
sudo /etc/init.d/apache2 stop
sudo /etc/init.d/mysql stop
Or, you can also type instead:
sudo service apache2 stop
sudo service mysql stop
After that, we again start the lampp services:
sudo /opt/lampp/lampp start
Now, there must be no problems while opening:
http://localhost
http://localhost/phpmyadmin
j00lz
2811 silver badge12 bronze badges
answered May 4, 2012 at 6:38
CompilingCyborgCompilingCyborg
4,75013 gold badges44 silver badges61 bronze badges
6
- Open config.default.php file under phpmyadmin/libraries/
- Find $cfg[‘Servers’][$i][‘host’] = ‘localhost‘;
Change to $cfg[‘Servers’][$i][‘host’] = ‘127.0.0.1‘; - refresh your phpmyadmin page, login
answered May 17, 2013 at 1:57
brucenanbrucenan
5849 silver badges20 bronze badges
0
At each point in these instructions, check to see if the problem is fixed. If so, great! Otherwise, continue.
- Get to Services. (I was able to right click the Apache launch icon to get there.)
- Scroll down to MySQL. Click to start. This will get rid of the #2002 error. Now you’ll have a new error:
#1045 — Access denied for user ‘root’@’localhost’ (using password: NO)
- Edit the
C:wampappsphpmyadmin3.5.1config.inc.phpfile, changing$cfg['Servers'][$i]['extension'] = 'mysqli';to instead be= 'mysql' - Open Services again and Stop MySQL
- While in Services, Start wampmysqld
This is convoluted, I know, but that’s what worked for me. Some posts may say you need a password in the config file, but you don’t. Mine is still «»
Hope this helps.
Jack
10.9k13 gold badges49 silver badges65 bronze badges
answered Oct 17, 2012 at 14:32
1
The problem might be with service mysql-server and apache2 running while system start. You can do the following.
sudo /opt/lampp/lampp stop
To stop already running default services
sudo service apache2 stop
sudo service mysql stop
To remove the services completely, so that they won’t create problem in next system-restart, If you are in ubuntu(debian)
sudo apt-get remove apache2
sudo apt-get remove mysql-server
If you are in redhat or other, You could use yum or similar command to uninstall the services
Then start the lampp again
sudo /opt/lampp/lampp start
Also, don’t install mysql-server in the system, because it might start in system start-up, occupy the port, and create problem for mysql of lampp.
answered Jul 5, 2014 at 11:09
RajanRajan
1,4914 gold badges21 silver badges35 bronze badges
1
I stopped MySQL sudo service mysql stop
and then started xammp sudo /opt/lampp/lampp start
and it worked!
answered Nov 17, 2018 at 17:59
0
Go to phpMyAdmin/config.inc.php edit the line
$cfg['Servers'][$i]['password'] = '';
to
$cfg['Servers'][$i]['password'] = 'yourpassword';
This problem might occur due to setting of a password to root, thus phpmyadmin is not able to connect to the mysql database.
And the last thing change
$cfg['Servers'][$i]['extension'] = 'mysql';
to
$cfg['Servers'][$i]['extension'] = 'mysqli';
Now restart your server. and see.
Alexander
23.4k11 gold badges62 silver badges73 bronze badges
answered Feb 17, 2013 at 7:49
Go to config.inc.php file using terminal by typing the following:
sudo gedit /opt/lampp/phpmyadmin/config.inc.php
The file will open in gedit.
Now open the file and edit
$cfg['Servers'][$i]['auth_type'] = 'localhost';
to
$cfg['Servers'][$i]['auth_type'] = 'cookie';
and keep the username as: root password:
Also make sure that the lines with username and password are not commented:
//$cfg['Servers'][$i]['user'] = 'root'; //$cfg['Servers'][$i]['password'] = '';
Make sure that // is removed from the above lines.
Phiter
14.5k14 gold badges50 silver badges84 bronze badges
answered May 12, 2016 at 12:49
PragyaPragya
571 silver badge12 bronze badges
please check the mysql.ini file in your xampp mysql installation… its found on xampp/mysql/bin directory
check the line 43
> log_error="mysql_error.log"
> #bind-address="127.0.0.1"
uncomment the line 43 if its still commented
answered May 3, 2012 at 7:00
NetoricaNetorica
18.3k17 gold badges72 silver badges108 bronze badges
3
Though I’m using Mac OS 10.9, this solution may work for someone else as well, perhaps on Ubuntu.
In the XAMPP console, I only found that phpMyAdmin started working again after restarting everything including the Apache Web Server.
No problemo, now.
answered Mar 23, 2014 at 17:40
Soren WagnerSoren Wagner
731 gold badge1 silver badge5 bronze badges
You can check it by connecting MySQL through the command prompt.
I think that your MySQL Database is blocked by firewall. Once stop all the services of antivirus software you have on your computer, then try to connect.
I faced this problem as well and rectified by blocking all firewalls..
venerik
5,7382 gold badges33 silver badges43 bronze badges
answered Sep 5, 2014 at 7:01
Goto xampp folder in local drive c, click on mysql folder, then click on bin and finally click on «mysqladmin» application. Then go back and refresh your browser and the problem is solved.
answered May 17, 2013 at 16:48
Здравствуйте. Не могу запустить веб-сервер. Перенес денвер на другой комп (asus vivotab 8). При старте веб-сервер не индицирует никаких ошибок. Однако PhpMyAdmin при запуске выдает ошибку:
—————-
#2002
The server is not responding (or the local server’s socket is not correctly configured).
Connection for controluser as defined in your configuration failed.
/—————-
брандмауэр у меня отключен
скайп не установлен
Попробовал установить еще один денвер с нуля (естественно, поедварительно остановил старый). При первом запуске все работает. Однако после первого перезапуска также появляется ошибка #3002phpMhAdmin.
На многих ресурсах юзеры советуют выкинуть денвер ибо убог и стар.
Решил попробовать OpenServer. Однако он вообще не запустился, выдвав при старте:
——————
-Не удалось запустить MySQL-5.5
-Сбой запуска!
/—————-
Помогите плз!
Где искать причину? Что еще можно попробовать сделать доя решения проблемы?
Learn how to solve the error 2002 of MySQL that prevents you from accessing PHPMyAdmin.
You was working yesterday with many databases perfectly, turn off the computer to sleep and the next day magically MySQL isn’t working ? Many developers have faced this idiotic issue and most people still don’t know why this happens (including me). A common solution, like every Systems engineer would do with a router that doesn’t work, is restart the service and it should work again. Pitifully this doesn’t work because you will need to clear the log files of InnoDB manually and we’ll show you how in this article.
Before apply the solution
In most of the cases, the error is caused just because MySQL can’t start at the port 3306. Probably because there’s another application using it, so be sure that no other application is using the port at the same time. If you already verified that the port used by MySQL isn’t being used by another application like Skype and the problem persists, then proceed with the solution mentioned in this article.
1. Go to the data folder of MySQL
To solve this problem, you need to locate the mysql folder in your xampp installation. This is usually just one version, so you may find it (with a default installation path) in C:xamppmysqldata. This folder contains mainly logs and all the databases on MySQL.
2. Backup Log files and delete them
Note
Normally, you can’t delete the files if the MySQL service is running. So if the service is active, stop it first and then try to remove the files.
Create a copy of the log files of mysql, namely the files ib_logfile0 and ib_logfile1. These files are log files created during the runtime for InnoDB. Normally, removing them will solve your issue as they will be created later, however create a security copy of those files somewhere else, so in case that it doesn’t work, you can still restore them and leaving xampp as it was from the beginning.
Once you have a copy of those files somewhere else (other directory), delete them from the original directory and proceed with the next step.
3. Restart MySQL and Apache
As final step restart the MySQL and Apache services in case they are running with the xampp control panel. After restarting those services, try to access again PHPMyAdmin at the URL http://localhost/phpmyadmin and you should be able to use PHPMyAdmin again.
Happy coding !

