无法在 Mac 上连接到 MySQL Workbench。无法连接到“127.0.0.1”上的 MySQL 服务器 (61) Mac Macintosh

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

Cannot connect to MySQL Workbench on mac. Can't connect to MySQL server on '127.0.0.1' (61) Mac Macintosh

mysqlmysql-workbench

提问by user3553260

Cannot connect to MySQL Workbench on mac. I get the following error: Could not connect, server may not be running. Can't connect to MySQL server on '127.0.0.1' (61) The help would be appreciated.

无法在 Mac 上连接到 MySQL Workbench。我收到以下错误:无法连接,服务器可能未运行。无法连接到“127.0.0.1”上的 MySQL 服务器 (61) 将不胜感激。

Thank You!

谢谢你!

回答by app_sciences

Ran into a similar issue and my problem was that MySQL installed itself configured to run on non-default port. I do not know the reason for that, but to find out which port MySQL is running on, run the following in MySql client:

遇到了类似的问题,我的问题是 MySQL 安装了自己,配置为在非默认端口上运行。我不知道原因,但要找出 MySQL 正在运行的端口,请在 MySql 客户端中运行以下命令:

SHOW GLOBAL VARIABLES LIKE 'PORT';

回答by MillaresRoo

Go to System preferences -> MySql and check the state of your MySql instance.

转到系统首选项 -> MySql 并检查您的 MySql 实例的状态。

回答by Tushar Relan

There may be one or multiple reasons if you are not able to connect to MAC OS X MySQL server with MySQL-workbench.

如果您无法使用 MySQL-workbench 连接到 MAC OS X MySQL 服务器,可能有一种或多种原因。

When you press 'test connection' you might see this error. This could be explained briefly if you go step by step through 'Configure server management..' On the basis of the red crosses you can filter out the real problem.

当您按“测试连接”时,您可能会看到此错误。如果您逐步完成“配置服务器管理..”,则可以简要说明这一点。根据红色叉号,您可以过滤掉真正的问题。

The most common problems are associated with the installation of MySQL-server. Few people either forget to install the server prior to installing MySQL-workbench. Some others would install a part of the product. Please check whether you have also installed all the 3 parts that comes with the MySQL-Server dmg(disk image) file which contains mysql-server package. Those 3 parts are: MySQL server, preference pane and startup item.

最常见的问题与 MySQL-server 的安装有关。很少有人会在安装 MySQL-workbench 之前忘记安装服务器。其他一些人会安装产品的一部分。请检查您是否还安装了包含 mysql-server 包的 MySQL-Server dmg(disk image) 文件附带的所有 3 部分。这 3 个部分是:MySQL 服务器、首选项窗格和启动项。

Note: If you haven't selected preference pane then you won't be able to start mysql server instance from the System preferences.

注意:如果您没有选择首选项窗格,那么您将无法从系统首选项启动 mysql 服务器实例。

After you make sure that you have installed each item then you can check server instance of your native mysql-server. Open System preferences from dock and click MySQL. Then click Start MySQL Server to start the server instance. If the server instance is stopped, then MySQL-workbench won't be able to connect to the MySQL server.

确保已安装每个项目后,您可以检查本机 mysql-server 的服务器实例。从 Dock 打开系统首选项,然后单击 MySQL。然后单击启动 MySQL 服务器以启动服务器实例。如果服务器实例停止,那么 MySQL-workbench 将无法连接到 MySQL 服务器。

If you are still facing issue, then you need to check the port of the connection which you are making. Default port is '3307'and NOT '3306'. You can check it with using the following command in mysql terminal:

如果您仍然遇到问题,那么您需要检查您正在建立的连接的端口。默认端口是'3307'而不是'3306'。您可以在 mysql 终端中使用以下命令进行检查:

SHOW GLOBAL VARIABLES LIKE 'PORT';

Please note that this process helps you to connect to the local instance. If you have to connect to a remote server, then you have to enter that specific IP and Port. Contact your server's administrator if you are facing the issue. As this question specifically states that the problem is related to connecting to the local instance, I am not writing checks that you may need to ensure.

请注意,此过程可帮助您连接到本地实例。如果您必须连接到远程服务器,则必须输入该特定 IP 和端口。如果您遇到问题,请联系您的服务器管理员。由于此问题明确指出问题与连接到本地实例有关,因此我不会编写您可能需要确保的检查。

回答by Valentin Bossi

This steps are all in the terminal:)->source

这一步都在终端里:) ->source

  1. Step make sure your server is running:
  1. 步骤确保您的服务器正在运行:

sudo /usr/local/mysql/support-files/mysql.server start

须藤/usr/local/mysql/support-files/mysql.server 启动

  1. Check MySQL version. "This also puts you in to a shell interactive dialogue with mySQL, type q to exit."
  1. 检查 MySQL 版本。“这也会让你进入一个与 mySQL 的 shell 交互对话,输入 q 退出。”

/usr/local/mysql/bin/mysql -v

/usr/local/mysql/bin/mysql -v

  1. Make your life easier: "After installation, in order to use mysql commands without typing the full path to the commands you need to add the mysql directory to your shell path, (optional step) this is done in your “.bash_profile” file in your home directory, if you don't have that file just create it using vi or nano:"
  1. 让您的生活更轻松:“安装后,为了使用 mysql 命令而无需键入命令的完整路径,您需要将 mysql 目录添加到您的 shell 路径中,(可选步骤)这是在您的“.bash_profile”文件中完成的您的主目录,如果您没有该文件,只需使用 vi 或 nano 创建它:”

cd ; nano .bash_profile

光盘;纳米 .bash_profile

paste in and save:

粘贴并保存:

export PATH="/usr/local/mysql/bin:$PATH"

导出路径="/usr/local/mysql/bin:$PATH"

"The first command brings you to your home directory and opens the .bash_profile file or creates a new one if it doesn't exist, then add in the line above which adds the mysql binary path to commands that you can run. Exit the file with type “control + x” and when prompted save the change by typing “y”. Last thing to do here is to reload the shell for the above to work straight away."

“第一个命令将您带到您的主目录并打开 .bash_profile 文件,或者如果它不存在则创建一个新文件,然后在上面的行中添加将 mysql 二进制路径添加到您可以运行的命令的行。退出文件键入“control + x”,并在提示时键入“y”保存更改。这里要做的最后一件事是重新加载外壳以使上述内容立即生效。”

source ~/.bash_profile mysql -v

源 ~/.bash_profile mysql -v

"You will get the version number again, just type “q” to exit."

“您将再次获得版本号,只需键入“q”即可退出。”

  1. Check out on which port the server is running:
  1. 检查服务器在哪个端口上运行:

in your terminal type in: mysql

在你的终端输入:mysql

and then

进而

SHOW GLOBAL VARIABLES LIKE 'PORT';

显示全局变量,如“端口”;

use everytime a semikolon in the mysql client (shell)!

每次在 mysql 客户端(shell)中使用分号!

now you know your port and where you can configure your server(in the terminal with mysql shell/client). but for a successful connection with MySQL Benchmark or an other client you have to know more. username, passwort hostname and port. after the installation the root user has no passwort so set(howtoSetPW) the passwort in terminal with mysql shell/client. and the server is running local. so type in root, yourPW, localhost and 3007. have fun!

现在您知道您的端口以及您可以在哪里配置您的服务器(在带有 mysql shell/客户端的终端中)。但是要成功连接 MySQL Benchmark 或其他客户端,您必须了解更多信息。用户名、密码主机名和端口。安装后,root 用户没有密码,所以在终端中使用 mysql shell/client设置(howtoSetPW)密码。并且服务器在本地运行。所以输入root,你的PW,本地主机和3007。玩得开心!

回答by Orhan Celik

In my case I had a previous mySQL server installation (with non-standard port), and I re-installed to a different directory & port. Then I got the same issue (in windows). To resolve, you click on home + add new connection.

就我而言,我以前安装了 mySQL 服务器(使用非标准端口),然后重新安装到不同的目录和端口。然后我遇到了同样的问题(在 Windows 中)。要解决,请单击主页 + 添加新连接。

If you need to know the port of your server, you can find it when you start My SQL command line client and run command status (as below). In windows it is via All Programs -> MySQL -> MySQL ServerX.Y -> MySQL X.Y Command Line Client

如果您需要知道您的服务器的端口,您可以在启动 My SQL 命令行客户端并运行命令状态(如下)时找到它。在 Windows 中,它是通过所有程序 -> MySQL -> MySQL ServerX.Y -> MySQL XY 命令行客户端

how to create

如何创造

how to find port

如何找到端口

回答by andrewoodleyjr

Try restarting the mysql or starting it if it wasn't started already. Type this within terminal.

尝试重新启动 mysql 或在它尚未启动时启动它。在终端中输入此内容。

mysql.server restart

mysql.server restart

To auto start go to the following link below:

要自动启动,请转到以下链接:

How to auto-load MySQL on startup on OS X Yosemite / El Capitan

如何在 OS X Yosemite / El Capitan 上启动时自动加载 MySQL

回答by Sdembla

I had the same issue, I solved this with the following steps:

我遇到了同样的问题,我通过以下步骤解决了这个问题:

  1. Install the MySql (DMG) from this link

  2. If the mysql package comes with the file name "mysql-5.7.13...." and "MySql.prefPane" then your life is really easy. Just click on "mysql-5.7.13...." and follow the instructions.

  3. After the installation is done, click on "MySql.prefPane" and checkout "Only for this user" in the popup. We use "MySql.prefPane" to start the mysql server as this is really imp because without this you will end up having errors.

  4. Click on Start MySql Server in the next dialog box.

    OR

    If you don't see "MySql.prefPane" in the package then follow these steps:

    1. Click on package "mysql-5.7.13...." and this will show you one password as soon as installation is done. That password is use to start the connection. You can change it. I will let you know in a while.

    2. After installation save the password (this is really important - you'll need it later), open terminal. $ cd /usr/local/mysql/bin/ $ ./mysql -u root -h localhost -p And then type the password from above. This should start mysql>

    3. To change the password: $ cd /usr/local/mysql/bin/ $ ./mysqladmin -u root -p password 'new_password' Enter Password: <type new password here> $ ./mysql -u root -h localhost -p ... and log in with the new password.

  1. 从此链接安装 MySql (DMG)

  2. 如果 mysql 包带有文件名“mysql-5.7.13....”和“MySql.prefPane”,那么你的生活真的很简单。只需单击“mysql-5.7.13....”并按照说明进行操作。

  3. 安装完成后,单击“MySql.prefPane”并在弹出窗口中签出“Only for this user”。我们使用“MySql.prefPane”来启动 mysql 服务器,因为这真的很糟糕,因为没有它你最终会出现错误。

  4. 在下一个对话框中单击启动 MySql Server。

    或者

    如果您在包中没有看到“MySql.prefPane”,请按照以下步骤操作:

    1. 单击包“mysql-5.7.13....”,安装完成后,这将显示一个密码。该密码用于启动连接。你可以改变它。一会我会告诉你的。

    2. 安装后保存密码(这很重要 - 稍后您将需要它),打开终端。 $ cd /usr/local/mysql/bin/ $ ./mysql -u root -h localhost -p 然后从上面输入密码。这应该开始mysql>

    3. 更改密码: $ cd /usr/local/mysql/bin/ $ ./mysqladmin -u root -p password 'new_password' Enter Password: <type new password here> $ ./mysql -u root -h localhost -p ... 并使用新密码登录。

After this you can go to MySql workbench and test connection. It should connect.

在此之后,您可以转到 MySql 工作台和test connection. 它应该连接。

回答by Li Mr

brew services start mysqldefualt set --bind-address=127.0.0.1 with /usr/local/Cellar/mysql/5.6.27/homebrew.mxcl.mysql.plist,so replace --bind-address=127.0.0.1 with --bind-address=* or --bind-address=0.0.0.0

brew services start mysql默认设置 --bind-address=127.0.0.1 与 /usr/local/Cellar/mysql/5.6.27/homebrew.mxcl.mysql.plist,所以用 --bind-address 替换 --bind-address=127.0.0.1 =* 或 --bind-address=0.0.0.0

回答by guntarion

I had the same problem. I removed mySQL completely, and reinstall it using homebrew.

我有同样的问题。我完全删除了 mySQL ,然后使用自制软件重新安装了它。

回答by Marcos QP

I had same problem, but it worked for me.

我有同样的问题,但它对我有用。

  1. check if you have mysql installed

    enter image description here

  1. 检查你是否安装了mysql

    在此处输入图片说明

If you don't have mysql installed, download from this link: https://dev.mysql.com/downloads/mysql/

如果您没有安装 mysql,请从此链接下载:https: //dev.mysql.com/downloads/mysql/

  1. follow this instructions to install https://dev.mysql.com/doc/mysql-osx-excerpt/5.7/en/osx-installation-pkg.html

  2. You can test the connection without any problem.

  1. 按照此说明安装 https://dev.mysql.com/doc/mysql-osx-excerpt/5.7/en/osx-installation-pkg.html

  2. 您可以毫无问题地测试连接。

(Sorry for my english, I agree fix me please)

(对不起,我的英语,我同意请修复我)

I Hope I've helped. Greetings.

我希望我有所帮助。你好。