ERROR 2003 (HY000): Can’t connect to MySQL server on localhost (10061)

I installed MySQL on Microsoft Windows 8 Using a noinstall Zip Archive. But when I tested by executing the following commands on windows prompt, the above error showed up.

C:> "C:MySQLbinmysqlshow" 

C:> "C:MySQLbinmysql" test

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

You don’t need to restart your windows. The easiest way to achieve this is

  1. Go to <Extracted folder location>/bin/
  2. Run mysqld (service)
  3. close the cmd prompt
  4. Run mysql.exe or the better way to do is add the location to PATH environment Variable

Method 2

Go to Run type services.msc. Check whether MySQL services is running or not. If not, start it manually. Once it started, type mysqlshow to test the service.

Method 3

  1. Go to bin directory copy the path and set it as a environment variable.
  2. Run the command prompt as admin and cd to bin directory.
  3. Run command : mysqld –install
  4. Now the services are successfully installed
  5. Start the service in service windows of os
  6. Type mysql and go

Method 4

Though it is an old question, I am adding my answer in it, because the solution that worked for me on Windows 7 as an admin user, is missing in the answers’ list. Though my solution is for installed MySQL, I am putting it for those who search for a solution for this error message. Here it is:

  1. Click on the Windows 7 start button and type taskmgr in the search bar
  2. Right click on the taskmgr program icon and select Run as administrator
  3. In the Task Manager window, go to the Services tab
  4. Right click on the MySQL service and click Start Service

Step 1 and 2Step 3 and 4

Method 5

The solution that worked for me is:

  1. Downloaded mysql-8.0.22-winx64.zip file
  2. Extracted the zip file
  3. Moved the extracted folder to C:/Program Files
  4. Opened cmd.exe as admin
  5. Navigated to the directory cd C:Program Filesmysql-8.0.22mysql-8.0.22-winx64bin
  6. mysqld -install (Service successfully installed)
  7. mysqld --initialize (no prompt)
  8. Opened services.msc
  9. Found MySQL
  10. Right-click and start

Method 6

I was stuck on this same issue for what felt like an eternity.

My problem was: I was running mysql from MAMP on port 8889, but when trying to connect to mysql from my command line, it was expecting port 3306. I was running out of ideas, so I tried:

mysql --port 8889

and happiness ensued:

Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 2
Server version: 5.6.34-log MySQL Community Server (GPL)

Method 7

Go to Run type services.msc. Check whether MySQL services is running or not. If not, start it manually.

Method 8

  1. Run your cmd as administrator.
  2. What you will see is like this:
    c:windowssystem32>
  3. Go to your bin location by using cd..
    like C:mysqlbin (my location of bin in my computer is what you are seeing so chose yours correctly)
  4. Run:
    $ C:mysqlbin>mysql --install
    
    Service successfully installed.
  5. Then run:
    $ C:mysqlbin>NET START MySql
    
    The MySql service is starting
    The MySql service was started successfully
  6. Then the last step is running:
    C:mysqlbin>mysql -u root - p admin

    It will ask for password don’t enter anything first time
    because it will use blank, and just press enter you are done.

And later you can set password too.

Method 9

I have a windows 8.1 machine and mysql was not running at all even after trying to start mysqld with no error logs. This solution worked for me:

  1. start cmd in admin mode
  2. type in “net start mysql”
  3. close current cmd window and open new cmd window
  4. type in “mysql”

The mysqld service should now be available.

Method 10

Had this issue in Windows 10 and MySQL 8. Resolved by following steps:
Searchbar(bottom left) > Task Manager > Run as administrator > Services > MySQL80

Method 11

Well that could have some reasons.

THe first one is that the MySQL server/service not started.

If he is started you should check out the logfiles, and make sure there are no problems.

You could also uninstall the MySQL service and install XAMPP.
With XAMPP it is easier to manage this services.

Method 12

Despite that my server was running, I had the same problem.
I found out that it was the port. So you need to specify the port:

mysql -u user -p --port 0000

The port on your machine may be different. To find out on which port mysql is running open the mysql ini file and look for port=. A port often used is 3306.

Example how to log on to mysql

mysql -u root -p --port 3306

Method 13

Test if the server is running. You can use netstat for this. See https://serverfault.com/questions/260239/unable-to-connect-to-mysql-through-port-3306

If it is running, it may be the firewall. You can turn that off to test if that is the problem.

See the following manual to install Mysql as a service: https://dev.mysql.com/doc/refman/5.5/en/windows-start-service.html

Method 14

First of all, you need to ensure the port number on which the server is running. Then you can run

mysql -u username -p --port portNumber
on the command line

Method 15

Executing the mysqld command can solve your problem.
My SQL version is 5.7.

Method 16

If you’re using the no install zip, you need to execute mysqld.exe first to start the service, and then execute mysql.exe to open your connection.

The no install is nice, but if you intend to do any serious work with MySQL, you may want to consider either using the MSI to do a proper installation, or if you’re doing web development work give XAMPP a try.

Method 17

Check Mysqld.exe file is in your bin folder. if it is not there , just copy that file from any other computer and paste it on your bin folder.Just double click. Then run mysql.its solved

Method 18

This error is flashed when we are trying to open mysql with out stating the service.

  1. Open cmd prompt
    to start the service type
    mysqld --console

    This will start the mysql service
    ERROR 2003 (HY000): Can't connect to MySQL server on localhost (10061)

  2. Don’t close this cmd prompt and open a new cmd prompt and
    type
    mysql -u root -p

    Then enter ur password
    ERROR 2003 (HY000): Can't connect to MySQL server on localhost (10061)

Method 19

Make sure your mysql is running in default port (3306) , if you are running mysql with different port (for example: 3307), you must specified the port number while connecting to the server.

If your port is different than default port, then try with this command.

mysql -u <username> -p --port<port number>

For eg:

mysql -u root -p --port 3307

Method 20

Go and search Services in Windows

Now search Mysql. Right Click on it. By Default it’s startup type will be ‘Automatic’. Click on Properties on right clicked menu.
You will find startup type Switch it to -> Manual So that We can start and stop by our choice.

Now Get Back and Right Click to Mysql on Services and Click Start.

Now Mysql has started successfully

To get started
Start Mysql Shell
& type command

shell.connect({host: 'localhost',user: 'root'})

Now type password

To type sql commands:-

/sql

ERROR 2003 (HY000): Can't connect to MySQL server on localhost (10061)

Method 21

I had the same problem. I tried all of the answers above (and some from other websites). In the end, my issue was that my cache wasn’t configured. I found that info in my error log and fixed it by changing the line in the file:

C:MAMPbinapacheconfextrahttp-ssl.conf

There I removed the double quotes from the line:

SSLSessionCache “shmcb:/some/example/path/ssl_scache(512000)”

to:

SSLSessionCache shmcb:/some/example/path/ssl_scache(512000)

and saved with Ctrl+S and closed the file.

Here’s the link that helped me:
https://wiki.apache.org/httpd/SSLSessionCache

Method 22

I faced the same problem couple of times and each time the reason was different:

  • The solution that worked first time was that by “Abhishek Oza” which is same as that of “amey91” (see above)
  • The second time, my server was on a different port number than the default one(3036),so i was not able to connect.So I had to specify
    the port number explicitly for making the connection which you can do
    simply by writing: “mysql –host=127.0.0.1 –port=8081(specify your
    port number here) mysql -u root -p

Method 23

In my case, which was a manual install using the .zip file.
I solved this by specifying the nonstandard MySQL and Data install locations in a my.ini.
https://dev.mysql.com/doc/refman/8.0/en/windows-create-option-file.html

Then I needed to run the data directory initialisation commands:
https://dev.mysql.com/doc/refman/8.0/en/data-directory-initialization-mysqld.html

Then running:
net start mysql

Method 24

There is a possibility that your installation of MYSQL got corrupted. The best thing you can do is to search for MYSQL INSTALLER on your system and then run it again.

It will not download the mysql server again, it will just help you to set it up.

After that, edit your environment variables path and add the bin folder of your mysql to it.

By now, it should work.

Method 25

I had a problem with most of these solutions . The fact that I couldn’t find the bin folder in my c drive. I tried solution offered here ” https://www.howtosolutions.net/2017/08/fixing-mysql-10061-error-after-migration-of-database-files/ “and vwala “welcome to the mysql monitor ….”

Method 26

In my case I have 2 different version of mysql in Windows OS and I solved the my problem by bottom step:

first stop all mysql service.

I create one config file in C:mysqldata.cnf with bottom data(my mysql is in “C:/mysql-5.0.96-winx64” directory ):

[mysqld]
datadir = C:/mysql-5.0.96-winx64/data
port = 3307

then I run bottom command in cmd:

C:mysql-5.0.96-winx64binmysqld --defaults-file=C:mysqldata.cnf --console

above step reference

then I create txt file in C:resetpass.txt with bottom data:

UPDATE mysql.user SET password=PASSWORD('ttt') WHERE user='root';

then run mysqld with bottom command:

C:mysql-5.0.96-winx64binmysqld --init-file=C:resetpass.txt --install mysql2 --console
net start mysql2

after these step you have one mysql service(with name mysql2) than run with port 3307.

I have 2 version of mysql with different user management tables(in version 5.0.96 user table difference with 5.5 version because of that I must be change table folder in first step)

you can run other mysql service with other port now(and you can run this steps with different datadir, service name and port for it again)

Method 27

  1. First make sure you have installed MYsql+Sqlyog(if you are using it.).
    • Start Registry Editor (Regedt32.exe).
  • Locate the following key in the registry:

    HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesTcpipParameters
    On the Edit menu, click Add Value, and then add the following registry value:

       Value Name: MaxUserPort
       Data Type: REG_DWORD
       Value: 65534

    This sets the number of ephemeral ports available to any user. The valid range is
    between 5000 and 65534 (decimal). The default value is 0x1388 (5000 decimal).

    On the Edit menu, click Add Value, and then add the following registry value:

       Value Name: TcpTimedWaitDelay
       Data Type: REG_DWORD
       Value: 30

    This sets the number of seconds to hold a TCP port connection in TIME_WAIT state before
    closing. The valid range is between 30 and 300 decimal, although you may wish to check
    with Microsoft for the latest permitted values. The default value is 0x78 (120 decimal).

    Quit Registry Editor.
    
    Reboot the machine.

Method 28

I will advise to use first check if my.ini exist in mysql folder in c drive or in windows folder
mysqld -install (Service successfully installed)
mysqld –initialize (no prompt)
Also another advise is not to use mysql 8, since it is not compatible with wordpress or any other opensource yet, there are lot of changes between version 5 and version 8, so if you are using mysql please use version 5.x.

Method 29

Steps to resolve the problem ->

  1. Go to command prompt and at root of c (c: if environment variable-path is set)
    type -> c:>mysqld -install.
  2. Then type -> c:mysqld --initialize
  3. Now create one .txt file (here in our example we are taking init.txt) at root of mysql(may vary according to your directory) ->c:MySQLinit.txt.
  4. Now open that .txt file(init.txt) and write in it ->
    ERROR 2003 (HY000): Can't connect to MySQL server on localhost (10061)

5.open Run console and write -> Services.msc

6.Then Services window will be open ,there select MYSQL,Double click It and press start

7.Finally open new Command prompt window and type at root of c (c:) ->c:>mysqlsh
due to this shell will execute and here you are ready to go….

Method 30

mysql -u root --port 3308

this one help me

port number from phpmyadmin default port is 3306

ERROR 2003 (HY000): Can't connect to MySQL server on localhost (10061)


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x