Some time on Windows Operating System we see an error: ERROR 2002 (HY000): Can’t connect to MySQL server on ‘localhost’ (10061)
You may have something similar error as below screenshot:

The issue behind the “ERROR 2002 (HY000): Can’t connect to MySQL server on ‘localhost’ (10061)” error is the Windows Operating System MySQL service is not started.
You can start the service by simply following below steps:
Step 1: Install MySQL with the command mysqld –install Step 1: Install MySQL with the command mysqld –install
You need to execute the below command:
mysqld --install
Open CMD/Command Prompt and execute the command as below:

Step 2: Initialize MySQL with mysqld –initialize Step 2: Initialize MySQL with mysqld –initialize
Keep open the terminal and execute the below command:
mysqld --initialize

Step 3: Start the MySQL Service in Windows Operating System Step 3: Start the MySQL Service in Windows Operating System
- Press
CTRL + R
, or Goto start and type “Run“. - And type the services.msc as below screenshot:

You will see the Services screen.
Now, Search for MySQL.
You’ll see something like below screenshot:

Now, At the left, you can see the Start the service.
Click on Start.
You can see after that something like below:

Done! MySQL will works Done! MySQL will works
To confirm that MySQL is working as expected. Execute the below command:
mysql --version
