MySQL Workbench:“无法在 127.0.0.1' (10061) 上连接到 MySQL 服务器”错误

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

MySQL Workbench: "Can't connect to MySQL server on 127.0.0.1' (10061)" error

mysqlmysql-workbench

提问by Mike Gledhill

I apologise.. I know this question has been asked many times before, but I've tried lots of suggestions, and simply can't find a solution.

我道歉.. 我知道这个问题之前已经被问过很多次了,但我已经尝试了很多建议,但根本找不到解决方案。

The problem: I have a MySQL database running on a hosted server. I have to use SSH to connect to it, and I have the relevant Public and Private Key files.

问题:我在托管服务器上运行了一个 MySQL 数据库。我必须使用 SSH 连接到它,并且我有相关的公钥和私钥文件。

I specifically want to use the PC version of MySQL Workbench, to access this database, for running queries, checking data, etc.

我特别想使用MySQL Workbench的 PC 版本来访问这个数据库,用于运行查询、检查数据等。

If I run Sequel Proon a Mac, it connects fine, and I can browse and query the database. No problems.

如果我在 Mac 上运行Sequel Pro,它连接良好,我可以浏览和查询数据库。没问题。

If I run the trial version of SQLyogon a PC, it also connects fine. No problems.

如果我在 PC 上运行SQLyog的试用版,它也可以正常连接。没问题。

But if I try to connect use MySQL's own "MySQL Workbench" application, using exactly the same settings and SSH Private Key file, it refuses to connect, throwing the well-known error:

但是如果我尝试使用 MySQL 自己的“ MySQL Workbench”应用程序连接,使用完全相同的设置和 SSH 私钥文件,它拒绝连接,抛出众所周知的错误:

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

无法连接到 127.0.0.1' (10061) 上的 MySQL 服务器

I find it frustrating, as, in SQL Workbench, I specified the "MySQL Hostname" to use, db01.mysql.vm.MyHostingServer.net, but Workbench seems to ignore it, and demand to connect to 127.0.0.1 instead.

我觉得这很令人沮丧,因为在 SQL Workbench 中,我指定了要使用的“MySQL 主机名” db01.mysql.vm.MyHostingServer.net,但 Workbench 似乎忽略了它,而是要求连接到 127.0.0.1 。

(I have read that Workbench says it needs the Public key file, but actually means the Private key file... and I have tried with both. I've also tried with MySQL Workbenchon a Mac, but that crashed all over the place, simply when I was typing in server names and passwords.. it was a mess !!)

(我读过 Workbench 说它需要公钥文件,但实际上意味着私钥文件......我已经尝试过两者。我也尝试过在 Mac 上使用MySQL Workbench,但是到处都崩溃了,就在我输入服务器名称和密码时..真是一团糟!!)

The hosting service I've gone with gives me limited permissions for changing MySQL settings, and given that Sequel Pro and SQLyog canconnect successfully, I don't want to start messing about and changing things randomly.

我使用的托管服务给了我更改 MySQL 设置的有限权限,并且考虑到 Sequel Pro 和 SQLyog可以成功连接,我不想开始随意乱改东西。

Any ideas...?

有任何想法吗...?

回答by ja4

Maybe you are not allowed to start the service "MySQL 55". Set the login information of Service "MySQL 55" as local!

也许您不允许启动服务“MySQL 55”。将服务“MySQL 55”的登录信息设置为本地!

enter image description here

在此处输入图片说明

To see the list of aviable services in Windows 7:

要查看 Windows 7 中可用的服务列表:

  1. Open a run box enter image description here
  2. Type services.mscand press return.
  3. Find the service MySQL55
  4. A right click of the MySQL55 Local Service shows Properties -> Log On enter image description hereenter image description here
  1. 打开一个运行框 在此处输入图片说明
  2. 键入services.msc并按回车键。
  3. 查找服务 MySQL55
  4. 右键单击 MySQL55 Local Service 显示 Properties -> Log On 在此处输入图片说明在此处输入图片说明

回答by user1349906

Even I had same problem, The reason was mysql service was not getting configured properly, when I installed it through 'MySQL installer'. Also it was not starting, when I tried to start the service manually.

即使我遇到了同样的问题,原因是当我通过“MySQL 安装程序”安装 mysql 服务时没有正确配置它。当我尝试手动启动服务时,它也没有启动。

So in my case it seemed be a Bug with the 'MySQL Installer', as editing the install path to a different one when the 'Developer default' was selected, the problem occurs.

因此,在我的情况下,它似乎是“MySQL 安装程序”的错误,因为在选择“开发人员默认设置”时将安装路径编辑为不同的路径,就会出现问题。

Solution (Not exactly a solution):

解决方案(不完全是解决方案):

  • Uninstalled the MySQL all products (completely)
  • Reinstalled, this time also I have selected 'Developer default', but didn't make any changes to the path or any thing. So the path was just 'C:\Program Files\MySQL' (the default one)
  • And just clicked Next Next...
  • Done, this time MySql was running fine.
  • 卸载MySQL所有产品(完全)
  • 重新安装,这次我也选择了“开发人员默认”,但没有对路径或任何东西进行任何更改。所以路径只是“C:\Program Files\MySQL”(默认的)
  • 只需单击下一步下一步...
  • 大功告成,这次 MySql 运行良好。

回答by Nikhil G

After making above improvement such as checking if mysql serviceis runningor not, you just need to give a small password while creating connection, it is ' 'or 1 time press on space-bar in case of GUI or workbench. After which you just need to validate your machine with server (validated HOST). For that purpose click on 'New Server Instance'and it will configure server/HOST on your behalf itself.

做完上面的检查是否mysql service正在运行等改进后,你只需要在创建连接时输入一个小密码,如果是' 'GUI或工作台,则是或按空格键1次。之后,您只需要使用服务器(已验证的主机)验证您的机器。为此,单击'New Server Instance'它将代表您自己配置服务器/主机。

I have done this successfullyjust a few couple of minutes ago. My workbench software is able to showall pre-installed databasesetc now.

几分钟前,我已经成功地完成了这项工作。我的工作台软件现在能够显示所有内容pre-installed databases

hope it will work for you as well.

希望它也适用于你。

Thanks!!!

谢谢!!!

回答by Yuvraj Patil

If you have installed WAMP on your machine, please make sure that it is running. Do not EXIT the WAMP from tray menu since it will stop the MySQL Server.

如果您的机器上安装了 WAMP,请确保它正在运行。不要从托盘菜单退出 WAMP,因为它会停止 MySQL 服务器。

回答by Orhan Celik

To connect to a new server, you click on home + add new connection. Put IP or webserver URL in new connection.

要连接到新服务器,请单击主页 + 添加新连接。将 IP 或网络服务器 URL 置于新连接中。

how to create

如何创造

回答by Hamid Hoseini

Just try to run the following command manually:

只需尝试手动运行以下命令:

C:\wamp\bin\mysql\mysql5.6.17\bin\mysqld.exe --console

It worked for me :)

它对我有用:)

回答by Koleslaw

Ran into the exact same problem as OP and found that leaving the "MySQL Server Port" empty in the MySQL Workbench connection solves the issue.

遇到与 OP 完全相同的问题,发现在 MySQL Workbench 连接中将“MySQL 服务器端口”留空可以解决问题。

回答by ChrisBD

Try placing the host name (db01.mysql.vm.MyHostingServer.net) in your windows host (C:\windows\system32\drivers\etc\host) file along with it's IP address and port number and see if that helps.

尝试将主机名 ( db01.mysql.vm.MyHostingServer.net)C:\windows\system32\drivers\etc\host连同它的 IP 地址和端口号一起放在 Windows 主机 ( ) 文件中,看看是否有帮助。