无法连接到“本地主机”上的 MySQL 服务器 (10061)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/119008/
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 12:05:11  来源:igfitidea点击:

Can't connect to MySQL server on 'localhost' (10061)

mysqllocalhostmysql5windows-firewall

提问by Cameron A. Ellis

I recently installed MySQL 5 on Windows 2003 and tried configuring an instance. Everything worked fine until I got to "Applying Security settings", at which point it gave me the above error (Can't connect to MySQL server on 'localhost' (10061)).

我最近在 Windows 2003 上安装了 MySQL 5 并尝试配置一个实例。一切正常,直到我进入“应用安全设置”,此时它给了我上述错误 ( Can't connect to MySQL server on 'localhost' (10061))。

I do have a port 3306 exception in my firewall for 'MySQL Server'.

我的防火墙中有一个端口 3306 异常,用于“MySQL 服务器”。

采纳答案by Chris

You'll probably have to grant 'localhost' privileges to on the table to the user. See the 'GRANT'syntax documentation. Here's an example (from some C source).

您可能必须将表上的“本地主机”权限授予用户。请参阅'GRANT'语法文档。这是一个示例(来自一些 C 源代码)。

"GRANT ALL PRIVILEGES ON %s.* TO '%s'@'localhost' IDENTIFIED BY '%s'";

"授予 %s 上的所有权限。* 给 '%s'@'localhost' 标识为 '%s'";

That's the most common access problem with MySQL.

这是 MySQL 最常见的访问问题。

Other than that, you might check that the user you have defined to create your instance has full privileges, else the user cannot grant privileges.

除此之外,您可以检查您定义的用于创建实例的用户是否具有完全权限,否则该用户无法授予权限。

Also, make sure the mysql service is started.

另外,确保mysql服务已启动。

Make sure you don't have a third party firewall or Internet security service turned on.

确保您没有打开第三方防火墙或 Internet 安全服务。

Beyond that, there's several pages of the MySQL forum devoted to this: http://forums.mysql.com/read.php?11,9293,9609#msg-9609

除此之外,MySQL 论坛有几个页面专门讨论这个问题:http: //forums.mysql.com/read.php?11,9293,9609#msg-9609

Try reading that.

试着读一下。

回答by ryanjones

Got this error on Windows because my mysqld.exe wasn't running.

在 Windows 上出现此错误,因为我的 mysqld.exe 没有运行。

Ran "C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqld" --installfrom the command line to add it to my services, ran services.msc (start -> run), found the MySQL service and started it.

“C:\ Program Files文件\的MySQL \ MySQL服务器5.5 \ BIN \ mysqld的” --install的命令行,将其添加到我的服务,然SERVICES.MSC(开始- >运行),发现MySQL服务,并启动它.

Didn't have to worry about it from there on out.

从那以后就不用担心了。

回答by JapoDeveloper

To resolve this problem:

要解决此问题:

  1. go to the task manager
  2. select Services tab
  3. find MySql service
  4. Running
  1. 转到任务管理器
  2. 选择服务选项卡
  3. 找到MySql服务
  4. 跑步

That's all.

就这样。

回答by Colin

I had difficulty accessing MySQL while connecting via a localhost connection on the standard port 3306, which worked fine when I installed and configured it for prior classes I had taken in MySQL and Java. I was getting errors like "error 2003" and "Cannot connect to MySql server on localhost (10061)". I tried connecting from both MySQL Workbench (5.2.35 CE) and Netbeans (7.2). I am using Windows 7 64 bit professional.

我在通过标准端口 3306 上的本地主机连接进行连接时访问 MySQL 有困难,当我为我在 MySQL 和 Java 中学习的先前课程安装和配置它时,它运行良好。我收到诸如“错误 2003”和“无法连接到 localhost (10061) 上的 MySql 服务器”之类的错误。我尝试从 MySQL Workbench (5.2.35 CE) 和 Netbeans (7.2) 进行连接。我使用的是 Windows 7 64 位专业版。

I tried typing in services.msc in the start menu search box, which opened the services dialog box to show all the services installed in windows. I scrolled down to MySQL and started this service. Subsequent attempts to connect to MySQL from MySQL WorkBench and from the command prompt succeeded.

我尝试在开始菜单搜索框中键入 services.msc,这会打开服务对话框以显示 Windows 中安装的所有服务。我向下滚动到 MySQL 并启动了这项服务。随后尝试从 MySQL WorkBench 和命令提示符连接到 MySQL 成功。

回答by Uday Hiwarale

  1. Make sure that your windows host file (located at c://windows/system32/drivers/etc.host) has following line. If not, add it at the end

    127.0.0.1 localhost
    ::1 localhost
    
  2. Sometimes mysql can not trigger Windows to force start host services if firewall blocks it, so start it manually

  1. 确保您的 Windows 主机文件(位于c://windows/system32/drivers/etc.host)具有以下行。如果没有,请在最后添加

    127.0.0.1 localhost
    ::1 localhost
    
  2. 有时如果防火墙阻止mysql无法触发Windows强制启动主机服务,因此手动启动它

win+run>>services.msc, select the "MySQL_xx" where "xx" is the name you have assigned to MySQL host services during setup. Click on 'start' to start from hyperlink appeared on left side.

win+ run>>services.msc,选择“MySQL_xx”,其中“xx”是您在安装过程中分配给 MySQL 主机服务的名称。单击“开始”从左侧出现的超链接开始。

回答by Mujtaba Zaidi

press Windows key + Rwrite "services.msc" enter search for "MYSQL56"write click on it and start the service

Windows key + R写“services.msc”输入搜索“MYSQL56”写点击它并启动服务

回答by Ted WIlcox

I tried Kuzhichamadam Inn's solution and found that a slight change needed to be made.

我尝试了Kuzhichamadam Inn的解决方案,发现需要做一些细微的改变。

MYSQL57 was a network service. I had tried this repeatedly with no success. When I opened services.msc I found another service for localhost: MySQL. I started that one using the process below and it worked.

MYSQL57 是一种网络服务。我已经反复尝试过,但没有成功。当我打开 services.msc 时,我发现 localhost 的另一个服务:MySQL。我使用下面的过程开始了那个,并且它起作用了。

run > services.msc > rightclick MySQL > properties >start

运行 > services.msc > 右键单击​​ MySQL > 属性 > 开始

回答by Sofia

English:

英语:

  • press Windows+ R
  • write "services.msc". Then press Enter
  • search for MySQL57 and right click
  • click on start the service
  • Windows+R
  • 写“services.msc”。然后按回车
  • 搜索 MySQL57 并右键单击
  • 点击启动服务

Fran?ais :

法语:

  • Appuyez sur la touche Windows+ R
  • écrire "services.msc" Puis appuyez sur Entrée
  • Recherchez MySQL57 et clic droit
  • Cliquez sur rédémarrer
  • Appuyez sur la touche Windows+R
  • écrire "services.msc" Puis appuyez sur Entrée
  • Recherchez MySQL57 et clic droit
  • Cliquez sur rédémarrer

回答by Muhammad Abbas

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

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

回答by Kuzhichamadam Inn

run > services.msc > rightclick MySQL57 > properties >set start type option to automatic

after restarting computer

重启电脑后

At cmd

在 cmd

cd: C:\

C :\> cd "C:\Program Files\MySQL\MySQL Server 5.7\bin"

it will become

它会变成

C:\Program Files\MySQL\MySQL Server 5.7\bin>

type mysql -u root -p

类型 mysql -u root -p

ie C:\Program Files\MySQL\MySQL Server 5.7\bin> mysql -u root -p

IE C:\Program Files\MySQL\MySQL Server 5.7\bin> mysql -u root -p

Enter password: ****

输入密码: ****

That's all

就这样

It will result in

它会导致

mysql>