7 Replies Latest reply on Oct 20, 2017 10:18 AM by Hatem Sabrey

    ssh tunnel to mySql database

    Nicolas Kramer

      Dear Reader,

       

      I'm trying to connect to a mySQL database through a SSH tunnel. But it just doesn't seem to work. A google search tells me to create a bridge on my localhost on port 3306, to the server on port 22. Doing so with multiple kinds of software doesn't yield any results.

       

      I tried bitvise SSH client with Client 2 Server tunnelling. From localhost on port 3306 to the server north.pole.com on port 22.

      Also PUTTY was unable to bridge correctly.

       

      I can log in with my credentials. And with the same settings I can successfully access and visualise the database with software like dbvisualizer.

       

      The error message I get on Tableau is:

       

      "MySQL database error 0x80004005: [MySQL][ODBC 3.51 Driver]Lost connection to MySQL server at 'reading initial communication packet', system error: 0

      Unable to connect to the server "localhost". Check that the server is running and that you have access privileges to the requested database.

      Unable to connect to the server. Check that the server is running and that you have access privileges to the requested database."

       

      I also tried redirecting to port 3306 on the server, and different ports on my localhost. Even ports I am sure are not used.

       

      Has anyone successfully connected a MySQL db through an SSH tunnelling?

       

      Thank you for your time,


      Nicolas Kramer

        • 1. Re: ssh tunnel to mySql database
          Daniel Smith

          Hi Nicolas,

           

          I came across this search for a solution to similar problem.

           

          Did you try using 127.0.0.1  instead of 'localhost'  for the server name? That fixed it for me.

          • 2. Re: ssh tunnel to mySql database
            Eric Summers

            Hi Nicolas,

             

            You have most likely resolved this but it is all I came across on Tableau's site when facing the port forwarding issue so I want to show how I was able to make this connection for others who are searching. The link below is the guide I followed to get mine connected. It is not Tableau specific but the issue is not related to anything in Tableau. It has everything to do with how you set up your SSH Tunnel in PuTTY or other. The port forwarding setup makes any call to a given port (that you define) redirect the call to the MySQL address on your server. You define the port in PuTTY and then use that port in Tableau along with the address of your mysql instance.

             

            I the first screenshot you will see I added 127.0.0.1:3306 as the destination. This is the address of MySQL as setup on your server. I included 9990 as the source port. This is the port that PuTTY will be monitoring for any given calls. Once you have these defined click add and then save your session and connect with you server credentials through PuTTY. Go to Tableau.

             

            In the second screenshot you will see that I used 127.0.0.1 for the server and 9990 for the port that I defined in PuTTY. You then add the credentials that correspond to your MySQL user that is setup on your server.

             

            I hope that this explanation will help someone do it a little quicker than I did the first time.

             

            SSH port forwarding for MySQL using PuTTY | katsande.com

            PuTTY forward.png

            Tableau:

            tableau port forwarded.png

            3 of 3 people found this helpful
            • 3. Re: ssh tunnel to mySql database
              Chris Pan

              To anyone who wants to connect to either mySQL or Postgres,

               

              the solution here really works. After connecting through putty ssh, in tableau you need to set the hostname to be 127.0.0.1, and then you are connected to the database! I've been reading through everything in this community for two days and finally I found the right answer. Many thanks!

              • 4. Re: ssh tunnel to mySql database
                Chris von Rabenau

                This should be set as answered. This is exactly how I have it set up on my Tableau server.

                • 5. Re: ssh tunnel to mySql database
                  zair ali

                  Old post but would like to thank you, the solution worked for me as well, very easy to setup.

                  • 6. Re: ssh tunnel to mySql database
                    desiree villota

                    Hi,

                     

                    This is not working for me. I'm new to tableau and I'm only using a trial version. I just want to test this for now and I've done everything that you said here but it doesn't seem to work. I'm not sure what I'm missing here.

                     

                    Can I ask for help?

                     

                     

                    Thank you

                    • 7. Re: ssh tunnel to mySql database
                      Hatem Sabrey

                      Hi

                       

                      great answer but this i how it is done using PuTTY on windows platforms what about MAC platform, there is no PuTTY for MAC??