简体   繁体   English

Sequel Pro 和 MySQL 连接失败

[英]Sequel Pro and MySQL connection failed

I just installed mysql on mac from Homebrew我刚刚从 Homebrew 在 mac 上安装了 mysql

brew install mysql

mysql -V

mysql  Ver 8.0.11 for osx10.13 on x86_64 (Homebrew)

from terminal it works and I can login to mysql but from Sequel Pro it says从终端它工作,我可以登录到 mysql 但从 Sequel Pro 它说

在此处输入图片说明

Unable to connect to host 127.0.0.1, or the request timed out.无法连接到主机 127.0.0.1,或请求超时。

Be sure that the address is correct and that you have the necessary privileges, or try increasing the connection timeout (currently 10 seconds).确保地址正确并且您具有必要的权限,或者尝试增加连接超时(当前为 10 秒)。

MySQL said: Authentication plugin 'caching_sha2_password' cannot be loaded: dlopen(/usr/local/lib/plugin/caching_sha2_password.so, 2): image not found MySQL 说:无法加载身份验证插件 'caching_sha2_password': dlopen(/usr/local/lib/plugin/caching_sha2_password.so, 2): image not found

can't figure out what I am missing无法弄清楚我错过了什么

This is because Sequel Pro is not ready yet for a new kind of user login, as the error states: there is no driver.这是因为 Sequel Pro 尚未准备好进行新的用户登录,正如错误所述:没有驱动程序。

mysql + homebrew mysql + 自制软件

Basically you will have to perform some actions manually, however- your database data won't be deleted like in solution below基本上您必须手动执行一些操作,但是 - 您的数据库数据不会像下面的解决方案一样被删除

  • Go to my.cnf file and in section [mysqld] add line:转到 my.cnf 文件并在[mysqld]部分添加行:

    default-authentication-plugin=mysql_native_password

  • Login to mysql server from terminal: run mysql -u root -p , then inside shell execute this command (replacing [password] with your actual password):从终端登录到 mysql 服务器:运行mysql -u root -p ,然后在 shell 中执行此命令(将[password]替换为您的实际密码):

    ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '[password]';

  • exit from mysql shell with exit and run brew services restart mysql .从mysql外壳,退出exit和运行brew services restart mysql

Should work.应该管用。

Quick fix (destructive method)快速修复(破坏性方法)

Quick fix for non-homebrew installs:非自制软件安装的快速修复:

Apple Logo > System Preferences > MySQL > Initialize Database , then type your new password and select 'Use legacy password' Apple Logo > System Preferences > MySQL > Initialize Database ,然后输入您的新密码并选择“使用旧密码”

After restart you should be able to connect.重启后应该就可以连接了。 Do it only on fresh installs, because you may lost your db tables otherwise.仅在全新安装时执行此操作,否则您可能会丢失 db 表。


my.cnf我的.cnf

The my.cnf file is located in /etc/my.cnf on Unix/Linux my.cnf 文件位于 Unix/Linux 上的 /etc/my.cnf


Alternatives备择方案

For those who is still struggling with Sequel Pro problems: Sequel Pro was a great product, but with tons of unresolved issues and last release being dated to 2016 perhaps it's a good idea to look for some alternatives. 对于那些仍在为 Sequel Pro 问题苦苦挣扎的人来说:Sequel Pro 是一款很棒的产品,但是有大量未解决的问题,并且最后一次发布的日期是 2016 年,也许寻找一些替代品是个好主意。 There is a fork of SequelPro called SequelAce that seems to be pretty stable and up-to-date, it keeps similar functionality, similar look and feel, yet at the same time it is devoid of old Sequel Pro problems SequelPro 有一个分支叫做 SequelAce,它看起来非常稳定和最新,它保持相似的功能,相似的外观和感觉,但同时它没有旧的 Sequel Pro 问题

TL;DR: Sequel Pro is dead since 2016. Don't downgrade your DB because of a tool. TL;DR:Sequel Pro 自 2016 年起就死了。不要因为工具而降级您的数据库。 Move on to an alternative tool.继续使用替代工具。

Update 2020: Sequel Pro is officially dead but unofficially alive! 2020 年更新:Sequel Pro 正式死亡,但非正式地活着! You can find the " nightly " builds that don't have this issue (ie support Mysql 8 auth) in here: https://sequelpro.com/test-builds您可以在此处找到没有此问题的“每晚”构建(即支持 Mysql 8 身份验证): https : //sequelpro.com/test-builds

Update 2021: Sequel Ace is a good similar alive alternative: https://github.com/Sequel-Ace/Sequel-Ace#installation (Credits to Maciej Kwas's answer) 2021 年更新:Sequel Ace是一个很好的类似活着的替代品: https : //github.com/Sequel-Ace/Sequel-Ace#installation (感谢 Maciej Kwas 的回答)


All the other solutions here are recommending changing your DB settings (making it less secure, as advertised by MySQL) for the tool you are using.这里的所有其他解决方案都建议为您正在使用的工具更改数据库设置(降低安全性,如 MySQL 所宣传的那样)。 That's not acceptable to me.这是我不能接受的。

I have always been a huge fan of Sequel Pro, even donated to it.我一直是 Sequel Pro 的忠实粉丝,甚至捐赠了它。 But, with all my passion and love, I am sorry if the tool doesn't have any release since 2016 .但是,以我所有的热情和爱,如果该工具自 2016 年以来没有任何版本,我很抱歉。 YOLO, and I need to move on! YOLO,我需要继续前进!

The alternative I found (from https://stackoverflow.com/a/55235533/2321594 , thanks to @arcseldon) is DBeaver which supports MySQL 8's new authentication (non-legacy) method.我发现的替代方案(来自https://stackoverflow.com/a/55235533/2321594 ,感谢@arcseldon)是DBeaver ,它支持 MySQL 8 的新身份验证(非传统)方法。

PS.附注。 The only trick in the tool side, not the DB side is when you are creating a MySQL 8 connection you might need to go to "Driver Properties" (later can be found in Edit Connection) and turn the value of allowPublicKeyRetrieval to true .工具方面而非数据库方面的唯一技巧是,当您创建 MySQL 8 连接时,您可能需要转到“驱动程序属性”(稍后可以在“编辑连接”中找到)并将allowPublicKeyRetrieval的值变为true

I needed this to connect to my MySQL container created using Docker.我需要它来连接到我使用 Docker 创建的 MySQL 容器。 To have the IP of MySQL be visible to the outside, for any other application in your ecosystem (not just this tool), you should either create a new user in MySQL, or pass -e MYSQL_ROOT_HOST=% in the run-time or as an ENV.为了让 MySQL 的 IP 对外可见,对于生态系统中的任何其他应用程序(不仅仅是这个工具),您应该在 MySQL 中创建一个新用户,或者在运行时传递-e MYSQL_ROOT_HOST=%或作为一个 ENV。

  1. Assuming you don't have a mysql configuration, echo the following to ~/.my.conf假设您没有mysql配置,将以下内容回显到~/.my.conf
[mysqld]
default-authentication-plugin=mysql_native_password
  1. Sign into mysql with mysql -u root -p使用mysql -u root -p登录mysql
  2. Set the root user password with ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '[PASSWORD]';使用ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '[PASSWORD]';设置 root 用户密码ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '[PASSWORD]'; where [PASSWORD] is a password of your choosing.其中[PASSWORD]是您选择的密码。
  3. Restart mysql with eg brew services restart mysql重启MySQL与例如brew services restart mysql

Sequel Pro is officially dead and no longer supports newer MySql features. Sequel Pro 正式死亡,不再支持更新的 MySql 功能。 However, the good news is that it was replaced by Sequel Ace which is available on GitHub and App store .然而,好消息是它被GitHubApp store上的Sequel Ace所取代。 The app is free of charge and looks like official replacement for Sequel Pro as the post was made by one of the collaborators of Sequel Pro .该应用程序是免费的,看起来像是 Sequel Pro 的官方替代品,因为该帖子是由Sequel Pro的一位合作者制作的

Ps.附言。 I decided to post this as an answer as others have not mentioned that there is now an up-to-date replacement for Sequel Pro我决定将此作为答案发布,因为其他人没有提到现在有最新的 Sequel Pro 替代品

If you connect to MySQL via root@127.0.0.1, make sure that you reset its password too!如果您通过 root@127.0.0.1 连接到 MySQL,请确保您也重置其密码!

ALTER USER 'root'@'127.0.0.1' IDENTIFIED WITH mysql_native_password BY '[password]'; ALTER USER 'root'@'127.0.0.1' IDENTIFIED WITH mysql_native_password BY '[password]';

It's working for me.它对我有用。 if you are getting this error :如果您收到此错误:

Unable to connect to host 127.0.0.1, or the request timed out.无法连接到主机 127.0.0.1,或请求超时。

Be sure that the address is correct and that you have the necessary privileges, or try increasing the connection timeout (currently 10 seconds).确保地址正确并且您具有必要的权限,或者尝试增加连接超时(当前为 10 秒)。

MySQL said: Authentication plugin 'caching_sha2_password' cannot be loaded: dlopen(/usr/local/lib/plugin/caching_sha2_password.so, 2): MySQL 说:无法加载身份验证插件 'caching_sha2_password': dlopen(/usr/local/lib/plugin/caching_sha2_password.so, 2):

Plz try this solution请试试这个解决方案

在此处输入图片说明

If anyone facing this issue and installed MySQL version > 8 through .dmg file;如果有人遇到此问题并通过.dmg文件安装了MySQL version > 8 downloaded it from the official link.从官方链接下载。 In that case please use this guideline .在这种情况下,请使用本指南 I am adding the same details below in case the link will not be available in the future.我将在下面添加相同的详细信息,以防将来无法使用该链接。

This issue is because you're using the new Strong Password Encryption which is a new feature in MySQL 8, if you installed MySQL 8 using the .dmg file, you can go to System Preferences > MySQL and then click on Initialize Database type your password and select the second option Use Legacy Password Encryption .这个问题是因为您使用的是 MySQL 8 中的新功能Strong Password Encryption ,如果您使用.dmg文件安装 MySQL 8,您可以转到System Preferences > MySQL ,然后单击Initialize Database输入您的密码并选择第二个选项Use Legacy Password Encryption

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM