【问题标题】:Can't connect with MYSQL workbench but can with Command line无法连接 MYSQL 工作台,但可以使用命令行
【发布时间】:2020-04-27 08:35:27
【问题描述】:

这似乎是一个非常具体的问题,但我们在使用 MYSQL 工作台时遇到了连接远程数据库的问题。工作台无法建立连接并给我错误

查询期间与 MySQL 服务器的连接丢失

我已经通过命令行测试了相同的凭据,它可以毫无问题地建立连接。此外,我尝试使用另一个程序(DBeaver)和同样的东西,我能够毫无问题地连接。所以这似乎是 MYSQL 工作台的问题。

事情变得有点复杂,因为我正在连接到 ProxySql 服务器(这就是为什么端口是 6033 而不是 3306),它指向带有数据库的服务器。我检查了安装,它按预期的方式工作。但我不明白为什么这会对我从 Workbench 连接的能力产生任何影响。如果我可以从命令行连接,我不应该能够从 Workbench 连接吗?

编辑: 我将日志设置为调试以获得更详细的输出

这是我尝试建立连接时记录的内容。

11:41:57 [DB3][SQL Editor Form]: Creating KeepAliveInterval timer...
11:41:57 [DB1][ mforms managed]: Looking up password for service: Mysql@IPADDRESS:6033, account: fuser
11:41:57 [DB1][ mforms managed]: Loading password cache
11:41:57 [DB1][ mforms managed]: Get special folder
11:41:57 [DB2][ mforms managed]: Decrypting password data
11:41:57 [DB2][ mforms managed]: Filling password cache
11:41:57 [DB1][ mforms managed]: Unloading password cache
11:41:57 [DB1][ mforms backend]: Looking up password for 'fuser'@'Mysql@IPADDRESS:6033' has succeeded
11:41:57 [DB1][ mforms managed]: Running a cancelable wait message
11:41:57 [DB3][    WQE backend]: Connecting SQL editor...
11:41:57 [DB3][       GRT task]: Sending task "execute sql queries" to dispatcher (wait)...
11:41:57 [DB1][  GRTDispatcher]: starting worker thread
11:41:57 [DB1][  GRTDispatcher]: worker thread running
11:41:57 [DB3][  GRTDispatcher]: Running task "execute sql queries"
11:41:57 [DB2][SQL Editor Form]: Notifying server state change of Mysql@IPADDRESS:6033 to not running
11:41:57 [ERR][SQL Editor Form]: SqlEditorForm: exception in do_connect method: Exception: Lost connection to MySQL server during query
11:41:57 [WRN][SQL Editor Form]: Lost connection to MySQL server during query
11:41:57 [ERR][SQL Editor Form]: Connection failed but remote admin does not seem to be available, rethrowing exception...
11:41:57 [ERR][  GRTDispatcher]: exception in grt execute_task, continuing: Exception: Lost connection to MySQL server during query
11:41:57 [DB3][  GRTDispatcher]: Task "execute sql queries" finished
11:41:57 [ERR][  GRTDispatcher]: worker: task 'execute sql queries' has failed with error:.Lost connection to MySQL server during query
11:41:57 [DB2][ mforms managed]: HUD window returned with code: 3
11:41:57 [DB2][ mforms backend]: forgetting cached password for 'fuser'@'Mysql@IPADDRESS:6033'
11:41:57 [DB2][  GRTDispatcher]: Main thread waiting for background thread to finish
11:41:57 [DB2][  GRTDispatcher]: Background thread finished
11:41:57 [ERR][SQL Editor Form]: SQL editor could not be connected: Lost connection to MySQL server during query
11:41:57 [ERR][SQL Editor Form]: Your connection attempt failed for user 'fuser' to the MySQL server at IPADDRESS:6033:
  Lost connection to MySQL server during query

Please:
1 Check that MySQL is running on address IPADDRESS
2 Check that MySQL is reachable on port 6033 (note: 3306 is the default, but this can be changed)
3 Check the user fuser has rights to connect to IPADDRESS from your address (MySQL rights define what clients can connect to the server and from which machines) 
4 Make sure you are both providing a password if needed and using the correct password for IPADDRESS connecting from the host address you're connecting from
11:41:57 [DB1][ mforms managed]: Showing an error to the user
11:41:57 [DB1][ mforms managed]: Hiding the wait message
11:41:57 [DB2][ mforms managed]: Wait message was not visible, nothing to do
11:41:57 [DB1][ mforms managed]: About to show a custom message box
11:41:57 [DB1][ mforms managed]: Creating and showing custom message box
11:41:57 [DB1][ mforms managed]: Running custom message box
11:41:58 [DB1][ mforms managed]: Custom message box closed
11:41:58 [DB2][            grt]: wb.form.showQueryConnectDialog finished in 3.96s

任何帮助将不胜感激。

【问题讨论】:

  • 查看这些链接link1, link2
  • 不走运。我将所有这些数字都设置得很高并重新启动了 Workbench,但没有任何变化。我也立即得到错误,它不会挂起几秒钟然后错误。它只是吐出错误。
  • 您是否尝试过阅读 ssh keep alive 上的链接?既然你提到了代理。只是说
  • 我尝试增加迁移时间和所有 ssh 连接超时字段。仍然无法建立连接。如果其中有任何用处,我已经用更详细的设置更新了日志输出。
  • 我也面临着类似的问题。我可以通过 putty 终端连接到数据库,但无法通过 MySQL 工作台连接。更令人惊讶的是,我能够通过工作台通过管理员用户进行连接,但不能通过任何其他用户进行连接。但是所有用户在 putty 中都可以正常工作

标签: mysql mysql-workbench


【解决方案1】:

就我而言,我的 mysql 数据库在 docker 上运行,当我使用以下语句创建用户时: CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';

当我尝试使用 DBeaver 从主机客户端连接到数据库时,这给了我错误。

我必须创建一个带有关注的用户才能使其工作。 CREATE USER 'username'@'%' IDENTIFIED BY 'password';

% 是允许用户从任何主机远程访问数据库的通配符。

【讨论】:

  • 正如目前所写,您的答案尚不清楚。请edit 添加其他详细信息,以帮助其他人了解这如何解决所提出的问题。你可以找到更多关于如何写好答案的信息in the help center
【解决方案2】:

我是来帮助你的。因此,一年前,当我在我的开发计算机中设置 MySQL 服务器时,我一直面临这些问题,并且在连接 MySQL 时遇到了无数问题,尤其是使用工作台时。所以,我认为我有能力回答这个问题。 因此,如果您能够使用命令行连接到 MySQL 服务器,那么预期的问题可能是:

  1. 无与伦比的版本兼容性:(如果您的 MySQL 服务器版本是 8.0.,那么您的 MySQL Shell 是 8.0 但 MySQL WorkBench 版本不是 8.0)。 在这种情况下,您可能需要检查您的版本并将它们升级到相同的版本。

  2. 检查 MySQL 工作台是否已关闭现有连接并尝试新连接:(尝试关闭现有连接并尝试使用登录凭据打开新连接 )

  3. 检查密码是否正确有时,由于其存储的缓存,密码会在工作台中自动更改

  4. 最后,检查连接类型(TCP/ssh)选择合适的连接类型

  5. 对不起,您可能需要查看负载均衡器配置和端口可访问性的权限

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-12-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-10
    • 1970-01-01
    相关资源
    最近更新 更多