| | |
how do I connect to MySQL server which is firewall protected?
![]() |
I am facing problem connecting problem connecting remote MySQL server which is firewall protected. I used the valid user name and password, but it throws me the error
OperationalError: (2003, "Can't connect to MySQL server on 'www.myreomtemysqlserver.com' (10061)")
I want to connect from python.
I searched in Google is there anyway so that I can connect MySQL server through SSH. MySQL server is running on UNIX box.
Is there any thing I do on server or is there any package to connect to MySQL which is firewall protected?
Please help me out.
Thanks.
kath.
OperationalError: (2003, "Can't connect to MySQL server on 'www.myreomtemysqlserver.com' (10061)")
I want to connect from python.
I searched in Google is there anyway so that I can connect MySQL server through SSH. MySQL server is running on UNIX box.
Is there any thing I do on server or is there any package to connect to MySQL which is firewall protected?
Please help me out.
Thanks.
kath.
•
•
•
•
Originally Posted by katharnakh
I am facing problem connecting problem connecting remote MySQL server which is firewall protected. I used the valid user name and password, but it throws me the error
OperationalError: (2003, "Can't connect to MySQL server on 'www.myreomtemysqlserver.com' (10061)")
I want to connect from python.
I searched in Google is there anyway so that I can connect MySQL server through SSH. MySQL server is running on UNIX box.
Is there any thing I do on server or is there any package to connect to MySQL which is firewall protected?
Please help me out.
Thanks.
kath.
ssh -L [local port]:[mysql host]:[connect-to-port]
Then aim your connection at localhost:[local port]
For mysql the default listen port is 3306
•
•
•
•
Originally Posted by pty
If the SSH port is open on the server's firewall (22 by default) you should be able to use a SSH tunnel to connect to mysql.
ssh -L [local port]:[mysql host]:[connect-to-port]
Then aim your connection at localhost:[local port]
For mysql the default listen port is 3306
I use the following code, to connect to MySQL server, sitting remote.
Python Syntax (Toggle Plain Text)
import MySQLdb db=MySQLdb.connect(host="myremote_MySQL_server.com", user="USERNAME", passwd="PASSWORD", port=3306)
Can you please tell me how do I tell MySQLdb.connect() to use the SSH tunnel, by running the above command
ssh -L [local port]:[mysql host]:[connect-to-port]
Thank you.
kath.
i presume you don't have access to change the firewall settings.
i'm no python expert so i got this from here:
mytunnel.py
open.tunnel.py
You should be able to use that principle to open a tunnel from your app then aim your db connection string's host at localhost.
i'm no python expert so i got this from here:
mytunnel.py
Python Syntax (Toggle Plain Text)
#!/usr/bin/python import socket def run(host,port): sd = socket.socket(socket.AF_INET, socket.SOCK_STREAM) try: # connect to the given host:port sd.connect((host, port)) except socket.error: return 0 else: return 1 sd.close()
open.tunnel.py
Python Syntax (Toggle Plain Text)
#!/usr/bin/python import os,mytunnel command = '/usr/bin/ssh zarski@ssh.server.com -i /root/identity-test/id_rsa -N -L 4000:localhost:3306' val = mytunnel.run('localhost',4000) if not val: pipe=os.popen(command,'r') pipe.close()
You should be able to use that principle to open a tunnel from your app then aim your db connection string's host at localhost.
![]() |
Similar Threads
- cannot connect to mysql server (PHP)
- Can't connect to MySQL server on 'localhost' (10061) (PHP)
- need help with iptable and mySQL server (Linux Servers and Apache)
- ERROR 2002: Can't connect to local MySQL server (MySQL)
- Can't connect to local MySQL server (MySQL)
Other Threads in the Python Forum
- Previous Thread: sessions in python
- Next Thread: Clearing screen in Python (was: omg noob prob plz help)
| Thread Tools | Search this Thread |
abrupt alarm ansi anti apache approximation array assignment backend beginner binary bluetooth builtin calculator character cmd converter countpasswordentry curved customdialog cx-freeze dan08 data decimals dictionary directory exe file float format function gnu halp heads homework http ideas inches input itunes java leftmouse library line lines linux list lists loop module mouse mysqlquery number numbers numeric output parsing path phonebook pointer prime programming push py2exe pygame python random recursion redirect schedule screensaverloopinactive script scrolledtext software sqlite ssh statictext statistics string strings sudokusolver terminal text thread time tlapse tuple twoup ubuntu unicode urllib urllib2 variable ventrilo webservice wikipedia wordgame write wxpython xlib





