我们在 Amazon Web Services 上有一个 EC2 和 RDS 实例。我通常首先使用 Putty 连接到服务器,然后通过隧道从本地主机访问数据库。
我现在尝试使用 TCP/IP over SSH 直接连接到数据库,但出现以下错误。我可以直接连接其他应用程序(例如 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]
最佳答案
我使用以下脚本连接到我的 rds 数据库-
ssh -L 3406:database.aws-server.rds.amazonaws.com:3306 -i username@100.100.100.100
此命令将在 mysql 默认端口 3306 的本地计算机端口 3406 上创建隧道。
之后您可以在应用程序中连接到 3406 端口
关于MySQL:无法通过 SSH 使用 TCP/IP 进行连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44082282/