| | |
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.
•
•
Join Date: Nov 2009
Posts: 1
Reputation:
Solved Threads: 0
I have the same problem. Has anyone found out how to do it?
Thanks,
Wendy
Thanks,
Wendy
•
•
•
•
I knew this concept, but thanks for your reply. But how do I implement the same in Python?
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.
![]() |
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: fileIO & pygame help
- Next Thread: how do you make a file with content from different lists .
| Thread Tools | Search this Thread |
abrupt accessdenied ansi anti apache application approximation argv array backend beginner book builtin calculator change converter countpasswordentry curved dan08 dictionaries dictionary dynamic edit enter file float format function heads homework import inches input java keyboard lapse library line lines linux list lists loop microphone mouse movingimageswithpygame mysqlquery newb number numbers numeric output parameters parsing path phonebook plugin pointer prime programming progressbar py2exe pygame pyopengl python random recursion redirect remote reverse scrolledtext session simple software sprite statictext statistics string strings syntax table terminal text textarea thread threading time tlapse trick tuple tutorial twoup ubuntu unicode unit urllib urllib2 variable wordgame wxpython





