Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8604635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:37:20+00:00 2026-06-12T02:37:20+00:00

I need to access a MySQL database on a remote server at my lab.

  • 0

I need to access a MySQL database on a remote server at my lab. The server is only accessible once I log in to a gateway server on the remote network:

local server => gateway server => MySQL server.

I can ssh to the gateway using port 24222.

I am using the PERL DBI module. This is what I use to connect when I am at the lab:

my $host="1.2.3.4";
my $database="dbname";
my $user="user";
my $pw="pass";
my $table="table";    

I imagine I have to set up a tunnel through the gateway server to the database server. How do I go about doing that? If the MySQL database were on the gateway, I could open a tunnel like so:

$ ssh -f user@gateway -L 3307:127.0.0.1:3306 -N 

How can I modify this to tunnel through the open port 24222 on the gateway through to the MySQL server on 1.2.3.4?


UPDATE:

Using @anttir’s answer I got it to work as follows.

  1. Set up the tunnel:

    $ ssh -fN -p 24222 user1@11.12.13.14 -L 3307:1.2.3.4:3306
    
  2. Set up the script variables:

    my $host="127.0.0.1";
    my $port = 3307;
    
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T02:37:22+00:00Added an answer on June 12, 2026 at 2:37 am

    With the command:

    $ ssh -f user@gateway -L 3307:1.2.3.4:3306 -N 
    

    This states that all connections to client localhost 3307 will be forwarded via the SSH tunnel to gateway and then connected to host 1.2.3.4 to port 3306.

    edit: If the SSH is on port 24222 then

    $ ssh -f user@gateway -p 24222 -L 3307:1.2.3.4:3306 -N 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to access the remote MYsql database from java which can be accessed
I need to disble remote access during nightly mysql maintenance on Linux server so
I need to connect to a remote mysql database in PHP. Specifically I have
I have the database mysql. I need to access it via a desktop application
I am working on a small PHP website. I need a MySql database access
I need to connect to a remote MySQL database and have created the following
I am new Ruby on Rails. I need to access mysql database of one
Here's the question, I need to connect to a remote MySQL database from my
i am connecting access to a mysql db. i need to put together two
i need to import a mysql file into my access db. how do i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.