Running a SQL query on my database behind the DMZ

Posted on 2009-12-16
Last Modified: 2012-05-08
Hi All,

I am working on a web app that is hosted on a web server in a demilitarized zone (DMZ). I need to run MySQL queries on the database that is on its own server which is on the same local network as the web server, but not accessible via the internet.

I can access the Web Server using putty, and the web server has MySQL installed. I can also SFTP sql files to the webserver.

I feel like I have all the Tools I'm just mising some knowhow! Any help on how I can execute these sql files would be greatly appreciated.

Thanks in advance,

Question by:equentin
    LVL 1

    Expert Comment

    Check this questio/post #: 24929908

    There you can see how you can connected to your web server.
    Once you are there is just a matter to write your query to a file and the run
    echo $query > sqlfile.txt
    mysql < sqlfile.txt

    you can ftp the files as well

    Let me now ..
    LVL 26

    Accepted Solution


    If you wish to use a local GUI tool (MySQL workbench, Toad, Eclipse...) you could set-up a tunnel via your putty session, to the web-server, on to the DB server.

    To do this load your saved session / enter the details for a new on then :

    1) select:  "Session->Connection->SSH->Tunnels" in the right hand pane
    2) stick a local port in source port e.g. 3306  enter the Mysql server IP and port in the Destination box e.g.  
    3) Click "add".
    4) Select: "Session", in the right hand pane.
    5) Click "Save" session.
    6) Click Open
    7) Once connected, in your local Mysql tool open a connection to the database via IP and port 3306


    Author Closing Comment

    The settings he mentions are changed in putty and are in addition to the putty login the the web box.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Hello to you all, I hear of many people congratulate AWS (Amazon Web Services) on how easy it is to spin up and create new EC2 (Elastic Compute Cloud) instances, but then fail and struggle to connect to them using simple tools such as SSH (Secure…
    Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
    Video by: Steve
    Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    758 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now