Today we consider the organization of SSH tunneling through PUTTY to MySQL.
Some programs require a connection to the database MySQL. For example mysql.exe console or other tools to work with databases of online stores or websites.
Very often, in the application, which requires a connection to the database MySQL, there are only 5 fields:
Some hosting providers allow direct access to the databases from outside, but others provide access to MySQL only through SSH protocol.
To build a SSH tunnel from your local machine to the database on the hosting, we recommend using PuTTY.
Next, write out step by step process.
- Download the PuTTY (you can download it from the developer website)
- Configure an SSH tunnel in PuTTY.
- 2.1 In the category of Session
- The field "Host Name (or IP address)": write server ip or host (for example Amazon EC2: ec2-54-227-195-17.compute-1.amazonaws.com)
- The field "Port": 22
- 2.2 In the category "Connection - SSH - Tunnels"
- Under "Add new forwarded port" in the Source port: specify your local port, such as 3306 (we recommend this as it is a standard port of MySQL)
- The field "Destination": localhost:3306
- Choose item "Local" and "Auto" Then click the button "Add" button.
- In the window "Forwarded Ports" should show our tunnel
- for example, "L3306 localhost: 3306."
- Then press the "Open" button.
- 2.3 Enter the username and password of SSH user host.
- All done, SSH tunnel is ready!
Now open your application that requires access to the database MySQL, write:
Login: Your login user database
Password: The password of the database user
Database: The database name
Port: 3306 (if required)
And press connect.