Learn how to solve the error 2002 of MySQL that prevents you from accessing PHPMyAdmin.

How to solve Xampp MySQL Error # 2002 - No connection could be made because the target machine actively refused it

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:\xampp\mysql\data. This folder contains mainly logs and all the databases on MySQL.

2. Backup Log files and delete them


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 !

Interested in programming since he was 14 years old, Carlos is a self-taught programmer and founder and author of most of the articles at Our Code World.

Become a more social person