Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Basic steps for using a Mysql SSH tunnel connection

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Preface

For security, root users of mysql only log in locally and do not authorize access through the external network. At this time, they can connect to the mysql database through SSH tunnels. The following are the basic steps for configuring a Mysql SSH tunnel connection.

I won't say much. Let's take a look at the detailed steps.

Delete remote login

Log in to mysql:

Mysql-uroot-p

View the access rights open to the user:

Select user, host from mysql.user

Remove unwanted access permissions, such as:

Delete from mysql.user where user='root' and host='%';flush privileges

Check again to verify whether the deletion was successful.

Build a tunnel

You can log in to the server through user name, password and RSA secret key. It is recommended to use the RAS secret key to place the local id_rsa.pub content in the server's ~ / .ssh/authorized_keys. How to generate the RSA secret key will not be discussed here.

Open a separate window, modify the ip and port corresponding to the following command, and execute:

Ssh-NCPf root@192.168.99.52-L 3388purl 127.0.1purl 3306

Parameter explanation:

C uses the compression function, which is optional and speeds up. P makes an outgoing connection using an unprivileged port. After completing the authentication and establishing the port forwarding, the f SSH is transferred to the background to run. N does not execute remote commands. This parameter is useful when only forwarding ports are open (supported by V2 version SSH)

Root@192.168.99.52 is the SSH user name and IP address that logs in to the MySQL server. -L 3388 127.0.0.1 3306 represents the mapping from port 3388 opened locally to port 127.0.0.1 of the mysql server. 127.0.0.1 can also be the private network ip or the public network ip of the server where the mysql resides.

Then, through the mysql tool, enter the corresponding user name and password to log in. Note that when logging in, the selected host address is localhost or 127.0.0.1. At the same time, open the access rights of the corresponding ip in the mysql database.

Summary

The above is the whole content of this article. I hope the content of this article has a certain reference and learning value for everyone's study or work. Thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report