日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

idea ssh连接mysql数据库_mysql命令行客户端如何通过ssh服务器连接数据库啊?

發布時間:2025/3/12 数据库 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 idea ssh连接mysql数据库_mysql命令行客户端如何通过ssh服务器连接数据库啊? 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

ssh到跳板機然后用 mysql 連接

利用ssh開啟一個隧道

我這里的MySQL服務器是192.168.41.83, 我要在192.168.41.72連接

首先在192.168.41.72執行命令開啟隧道

[root@mysql-test-72 ~]# ssh -NPf -o StrictHostKeyChecking=no root@192.168.41.83 -L 3305:127.0.0.1:3306

root@192.168.41.83's password:

[root@mysql-test-72 ~]#

-f: 完成連接后轉入后臺運行

-N: 不執行遠程命令

-o StrictHostKeyChecking=no: 不提示是否要選擇yes

3305: 本地端口

127.0.0.1:3306: 遠程機器端口

檢查端口狀態

[root@mysql-test-72 ~]# netstat -ntlp

Active Internet connections (only servers)

Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name

tcp 0 0 192.168.41.72:9991 0.0.0.0:* LISTEN 20409/mmm_agentd-te

tcp 0 0 127.0.0.1:3305 0.0.0.0:* LISTEN 28339/ssh

...

發現已經開啟3305端口,嘗試連接

[root@mysql-test-72 ~]# mysql -umytest -p -P3305 -h127.0.0.1

Enter password:

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 698103

Server version: 5.7.21-log MySQL Community Server (GPL)

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show variables like 'hostname';

+---------------+---------------+

| Variable_name | Value |

+---------------+---------------+

| hostname | mysql-test-83 |

+---------------+---------------+

1 row in set (0.01 sec)

連接成功

總結

以上是生活随笔為你收集整理的idea ssh连接mysql数据库_mysql命令行客户端如何通过ssh服务器连接数据库啊?的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。