I'm running MySQL 5.6.30 - MySQL Community Server (GPL) on ubuntu-16.04-x86_64 and I'm using phpMyAdmin 4.7.7.

Sometimes, without doing anything on the Server or phpMyAdmin, I'm getting this error message on my websites:

Connection failed: SQLSTATE[HY000] [2002] Connection refused

When trying to log in into phpMyAdmin I'm getting these four error messages:

#2002 - No such file or directory – The server is not responding (or the local server's socket is not correctly configured).


mysqli_real_connect(): (HY000/2002): No such file or directory


Connection for controluser as defined in your configuration failed.


mysqli_real_connect(): (HY000/2002): No such file or directory

After making a reboot everything is working fine as normal, there are no error messages any more and I'm able to login into phpMyAdmin.

Why does it happen? Any ideas?

  • Check your logs – Panther Dec 30 '17 at 17:55

I faced that similar problem using lamp , check if you may have more than two MySQL path like in

Find all the other mysql installed in your system

whereis mysql

mysql: /opt/lampp/bin/mysql /opt/lampp/bin/mysql.server /usr/share/man/man1/mysql.1.gz

Now if in you're system two MySQL if overlapping then remove others and keep only one MySQL installed by lamp

sudo rm -rf /etc/mysql  

Here is the link I found for apache2 i did the same with mysql and it's working http://xmodulo.com/how-to-uninstall-and-remove-apache2-on-ubuntu-debian.html

Finally stop all the MySQL existing service running

sudo service mysql stop
sudo /etc/init.d/apache2 stop
sudo /opt/lampp/lampp start

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy