MySQL:无法通过SSH使用TCP / IP进行连接

时间:2017-05-20 05:29:19

标签: mysql amazon-web-services ssh amazon-ec2 amazon-rds

我们在Amazon Web Services上有一个EC2和RDS实例。我通常首先使用Putty连接到服务器,然后通过我的localhost隧道访问数据库。

我现在尝试通过SSH使用TCP / IP直接连接到数据库,但是出现以下错误。我可以直接连接其他应用程序,如FileZilla,而无需创建任何隧道,但无法连接MySQL。请指教。 known_hosts文件中没有条目。

错误:

[Window Title]
MySQL Workbench

[Main Instruction]
Failed to Connect to MySQL at database.aws-server.rds.amazonaws.com:3306 through SSH tunnel at username@100.100.100.100:22 with user username

[Content]
Cannot open SSH Tunnel: Error connecting SSH tunnel: The host 100.100.100.100 fingerprints mismatch.
Expected key: hjd83iuwe98jdoiw8euoqeuo83eqe308
Server sent: 8ru84ru8ur984u8djc0938y4jddj398e
Please verify if it's correct.
To continue, delete entries for the host from the C:\Users\<USER>\AppData\Roaming\MySQL\Workbench\ssh\known_hosts file.

[OK]

2 个答案:

答案 0 :(得分:1)

我使用以下脚本连接到我的rds数据库 -

ssh -L 3406:database.aws-server.rds.amazonaws.com:3306 -i username@100.100.100.100

此命令将在mysql的默认端口3306的本地计算机端口3406上创建一个隧道。

之后,您可以在应用程序中的3406端口进行连接

答案 1 :(得分:0)

在AWS RSD中,单击“ VPC安全组”,然后将关联的EC2的入站流量源更改为任意位置。显然,问题出在安全组的源IP地址。希望这会有所帮助。