MySQL : How to fix Can't connect to MySQL server on localhost 10061 error

Fixing MySql 10061 error

A few months ago, when I installed MySQL server on Windows 10 to run WordPress locally, I chose to have the database files on my main SSD drive. As it was slowly filling up, I decided to migrate the MySQL database files to another drive. I assumed all I needed to do is to update a path for datadir option in my.ini configuration file, but that didn't work. After the database location move, starting the MySQL server gave me the 10061 error "Can't connect to MySQL server" error. Luckily, the fix was quite simple.

I got the following MySQL Workbench Connect error, when starting the MySQL server:

MySQL error - could not connect to MySQL - error code 10061 2003
Could not connect to MySQL: Can't connect to MySQL Server on 'localhost' (10061) (code 2003)

The MySQL Notifier's "Startup Message Log" contained the following:

Starting server...
Server start done.
Checking server status...
Trying to connect to MySQL...
Can't connect to MySQL server on 'localhost' (10061) (2003)
Assuming server is not running

As I mentioned, the datadir option in the main my.ini configuration file didn't work, but I also found my.ini file in the following path C:\ProgramData\MySQL\MySQL Server 5.7. I fixed the datadir path there too, but that didn't do anything.

In the end, the solution for me was to reconfigure the MySQL Install.

To reconfigure the MySQL install, we do the following steps:

  1. In Start Menu, search for "mysql". Among the results, you should see the "MySQL Installer - Community". Run it.
    Note: If you don't find it, open the Windows Explorer and find the MySQLInstaller.exe file inside the following path for Windows 10:
    C:\Program Files (x86)\MySQL\MySQL Installer for Windows\
  2. MySQL Installer window will show up as shown below. Find "MySQL Server" under Product and click on "Reconfigure" link.

    MySQL Installer Community

    Click image to enlarge
  3. The MySQL Installer will show up (the same one you used for the first MySQL Server installation). Go through all the steps.

    MySQL server installer

    Click image to enlarge

After the MySQL Installer was finished, I started the MySQL service again. This time, the "Startup Message Log" on The MySQL Notifier was showing that the server started successfully:

Starting server...
Server start done.
Checking server status...
Trying to connect to MySQL...
Connection succeeded
Assuming server is running

Conclusion

There are many suggestions on the web about how to solve the MySQL 10061 error. The one that worked for me was to run the MySQL Installer - Community and then choose "Reconfigure" for the MySQL server product. I hope you have found this article helpful. If you fixed this issue using another way, drop a comment and let us know.

44 Comments

Click HERE to add your Comment
  1. Matt
    January 3, 2018
    • Aldous Everard
      December 9, 2019
      • Nkosiyapha
        April 1, 2021
    • Alexandra Vremeroiu
      December 11, 2019
      • admin
        December 11, 2019
        • Nkosiyapha
          April 1, 2021
        • admin
          April 1, 2021
  2. akbakir
    May 8, 2018
  3. Bobby
    June 1, 2018
    • sudhan
      September 17, 2019
  4. Xaim
    June 5, 2018
  5. Korean
    June 9, 2018
  6. Addy
    June 24, 2018
  7. Cristian
    July 29, 2018
  8. Raul Rivero Rios
    August 27, 2018
  9. Kevin
    September 11, 2018
  10. Chris
    November 8, 2018
  11. Memed
    November 9, 2018
  12. jhona
    November 15, 2018
  13. sharon
    December 24, 2018
  14. Anand Banse
    January 3, 2019
  15. Luigi.hu
    March 14, 2019
  16. Al
    March 16, 2019
    • admin
      March 16, 2019
  17. Alice
    April 6, 2019
  18. Ranbeer Kumar
    May 31, 2019
  19. Unmesh Kumar
    June 5, 2019
  20. ADISU
    July 8, 2019
  21. Devin
    August 28, 2019
  22. Kutaro
    September 17, 2019
  23. Tony from Nairobi
    October 28, 2019
  24. Diz
    December 9, 2019
  25. Aa
    January 12, 2020
  26. Slots
    January 22, 2020
  27. Meredith
    August 14, 2020
  28. C
    September 10, 2020
  29. Randy
    December 17, 2020
  30. Lakshmi
    December 25, 2020
  31. Your love
    January 21, 2021
  32. Aayusmita
    February 3, 2021
  33. me
    February 12, 2021
    • admin
      February 13, 2021
  34. Dipesh
    September 9, 2021
  35. Divyank
    February 7, 2022

Write a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.