错误 2003 (HY000):无法连接到本地主机上的 MySQL 服务器 (10061)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17426052/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 18:03:21  来源:igfitidea点击:

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

mysql

提问by Foreever

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.

我使用 noinstall Zip Archive 在 Microsoft Windows 8 上安装了 MySQL。但是当我通过在 Windows 提示符下执行以下命令进行测试时,出现了上述错误。

C:\> "C:\MySQL\bin\mysqlshow" 

C:\> "C:\MySQL\bin\mysql" test

Please help me.

请帮我。

回答by debiansse

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

您无需重新启动 Windows。实现这一目标的最简单方法是

  1. Goto /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
  1. 转到 /bin/
  2. 运行 mysqld(服务)
  3. 关闭cmd提示
  4. 运行 mysql.exe 或者更好的方法是将位置添加到 PATH 环境变量

Thanks

谢谢

回答by Dineshkumar Ponnusamy

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

转到运行类型services.msc。检查 MySQL 服务是否正在运行。如果没有,请手动启动。启动后,键入mysqlshow以测试服务。

回答by kavi temre

i also face the same problem. try it

我也面临同样的问题。尝试一下

  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
  1. 转到 bin 目录复制路径并将其设置为环境变量。
  2. 以管理员身份运行命令提示符并 cd 到 bin 目录:
  3. 运行命令:mysqld –install
  4. 现在服务安装成功
  5. 在os的服务窗口启动服务
  6. 输入 mysql 并开始

回答by Abhishek Oza

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:

虽然这是一个老问题,但我将我的答案添加到其中,因为作为管理员用户在 Windows 7 上对我有用的解决方案在答案列表中缺失。虽然我的解决方案是针对已安装的 MySQL,但我将其用于搜索此错误消息的解决方案的人。这里是:

  1. Click on the Windows 7 start button and type taskmgrin 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 Servicestab
  4. Right click on the MySQLservice and click Start Service
  1. 单击 Windows 7 开始按钮并taskmgr在搜索栏中键入
  2. 右键单击 taskmgr 程序图标并选择 Run as administrator
  3. 在任务管理器窗口中,转到Services选项卡
  4. 右键单击该MySQL服务,然后单击Start Service
Step 1 and 2步骤 1 和 2Step 3 and 4第 3 步和第 4 步

回答by amey91

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:

我有一台 Windows 8.1 机器,即使在尝试启动没有错误日志的 mysqld 之后,mysql 也根本没有运行。这个解决方案对我有用:

  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"
  1. 以管理员模式启动cmd
  2. 输入“net start mysql”
  3. 关闭当前 cmd 窗口并打开新的 cmd 窗口
  4. 输入“mysql”

The mysqld service should now be available.

mysqld 服务现在应该可用。

回答by bokino12

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

转到运行类型services.msc。检查MySQL服务是否正在运行。如果没有,请手动启动。

回答by Samvit Mishra

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

在 Windows 10 和 MySQL 8 中存在此问题。通过以下步骤解决:搜索栏(左下)> 任务管理器 > 以管理员身份运行 > 服务 > MySQL80

回答by akritskiy

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:

我的问题是:我在端口 8889 上从 MAMP 运行 mysql,但是当尝试从我的命令行连接到 mysql 时,它需要端口 3306。我的想法用完了,所以我尝试:

mysql --port 8889

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)

回答by Ashish Kumar

Hey this is not a big issue what you need to do is.....

嘿,这不是什么大问题,你需要做的是......

1. Run your cmd as administrator.

2.What you will see is like this
c:\windows\system32>

3.Go to your bin location by using cd..
like C:\mysql\bin(my location of bin in my computer is what you are seeing so chose yours correctly)

4.C:\mysql\bin>mysql --install
  Service successfully installed.

5.C:\mysql\bin>NET START MySql
 The MySql service is starting
 The MySql service was started successfully

Then last step is

然后最后一步是

6.C:\mysql\bin>mysql -u root - p admin
It will ask for password don't enter anything first time because it will use blank, n just press enter you are done.

N later you can set password too...:)

N 以后你也可以设置密码...:)

回答by SPRBRN

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

测试服务器是否正在运行。您可以为此使用 netstat。见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

看下面的手册将Mysql安装为服务:https: //dev.mysql.com/doc/refman/5.5/en/windows-start-service.html