简体   繁体   English

如何连接到MySQL Workbench?

[英]How to connect to MySQL Workbench?

I've bought a server from CloudAtCost.com and all the information it gives me about my server is Server ID, IP Address, Netmask, and Gateway. 我已经从CloudAtCost.com购买了服务器,它提供给我的有关服务器的所有信息是服务器ID,IP地址,网络掩码和网关。 I can SSH in just fine, but I can't get MySQL Workbench to connect to it. 我可以使用SSH正常运行,但无法使MySQL Workbench连接到它。 I've tried both Standard (TCP/IP) and Standard TCP/IP Over SSH. 我已经尝试了标准(TCP / IP)和基于SSH的标准TCP / IP。

I figured it out. 我想到了。 I was using "user" as my username when I needed to use "root". 当我需要使用“ root”时,我使用“ user”作为用户名。

MySQL server needs to be running. MySQL服务器需要正在运行。

Network connections need to be enabled. 需要启用网络连接。

You need to know what port MySQL is running on (default is 3306). 您需要知道MySQL在哪个端口上运行(默认为3306)。

If reverse DNS lookup has not been disabled, MySQL has to be able to resolve IP address to hostname. 如果尚未禁用反向DNS查找,则MySQL必须能够将IP地址解析为主机名。

MySQL User has to be created and assigned a password, a username and host, host is either the specific host connecting or (less secure) a '%' wildcard for host. 必须创建MySQL用户并为其分配密码,用户名和主机,主机要么是连接的特定主机,要么是(不太安全)主机的'%'通配符。 If DNS lookups are disabled, host will be an IP address. 如果禁用DNS查找,则主机将是IP地址。

Connections to the MySQL port (by default it's 3306) may be "blocked" by firewall... 到MySQL端口的连接(默认为3306)可能被防火墙“阻止”了。

There are a lot of possible reasons. 很多可能的原因。


When we can't connect, there's usually a MySQL error message that indicates the kind of problem encountered. 当我们无法连接时,通常会出现一条MySQL错误消息,指出遇到的问题类型。


But, my preference would be to only allow IP connections from 127.0.0.1. 但是,我的选择是允许来自127.0.0.1的IP连接。 (We always turn off reverse dns lookups on our MySQL servers.) (我们总是在我们的MySQL服务器上关闭反向DNS查找。)

I'd use ssh port forwarding (tunneling). 我会使用ssh端口转发(隧道)。 Choose a port to use on your local machine, eg 13306, and configure SSH to "forward" connections to that port through the ssh connection... 选择要在本地计算机上使用的端口,例如13306,然后将SSH配置为通过ssh连接“转发”到该端口的连接...

You can configure that in the .ssh/config for the specific remote server, eg 您可以在.ssh / config中为特定的远程服务器进行配置,例如

Host remoteserver
  LocalForward 13306 localhost:3306

You'd need to first ssh to the remoteserver, and keep that session open. 您需要首先SSH到远程服务器,并保持该会话打开。

Then on your local machine, MySQL Workbench would connect to localhost port 13306 . 然后在您的本地计算机上,MySQL Workbench将连接到localhost端口13306 On the MySQL server side, that will be seen as coming from IP address 127.0.0.1, 在MySQL服务器端,这将被视为来自IP地址127.0.0.1,

Obviously, you'd need to have a user created, eg 显然,您需要创建一个用户,例如

GRANT USAGE ON *.* TO myusername@'127.0.0.1' IDENTIFIED BY 'mypassword'

And grant appropriate privileges. 并授予适当的特权。

转到Mysql Workbench>服务器状态>记下端口号,并将主机名指定为localhost:您的端口号,通常是3306

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

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