Python Forum
connect to remote database via python script
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
connect to remote database via python script
#1
Hi,

I am able to connect to local database via python script.
For ex: MySQLdb.connect("localhost","testuser","test123","test" )

I want to connect to remote database via python script.

Could you please help.
Reply
#2
You can probably replace the "localhost" by the host's IP address such as "127.0.0.1"
Reply
#3
Getting the below error:

# python test.py
Error:
Traceback (most recent call last): File "test.py", line 6, in <module> db = MySQLdb.connect("1.2.3.4","testuser","test123","test" ) File "/usr/lib/python2.7/dist-packages/MySQLdb/__init__.py", line 81, in Connect return Connection(*args, **kwargs) File "/usr/lib/python2.7/dist-packages/MySQLdb/connections.py", line 204, in __init__ super(Connection, self).__init__(*args, **kwargs2) _mysql_exceptions.OperationalError: (2003, "Can't connect to MySQL server on '1.2.3.4' (110)")
Are there any other settings required for binding the remote ip of the remote database
Reply
#4
Is your server's IP address '1.2.3.4' ? Try to connect to the mysql server out of python (such as with the mysql command in a terminal).
Reply
#5
current system ip for example: x.y.z.k

I am trying to connect to the remote database of the remote server i.e 1.2.3.4

connecting to 1.2.3.4 from x.y.z.k



Error:
# mysql --host=1.2.3.4 --user=testuser --password=test123 TEST mysql: [Warning] Using a password on the command line interface can be insecure. ERROR 2003 (HY000): Can't connect to MySQL server on '1.2.3.4' (111)
Reply
#6
Did you check the troubleshooting page?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Triggering a ps1 script in remote windows server via http python request jasveerjassi 1 383 Jan-26-2024, 07:02 PM
Last Post: deanhystad
  python script is hanging while calling a procedure in database prasanthi417 4 526 Jan-17-2024, 02:33 PM
Last Post: deanhystad
  connect sql by python using txt. file dawid294 2 445 Jan-12-2024, 08:54 PM
Last Post: deanhystad
  How to Connect to PostgreSQL Through Jump Server and SSH Tunnel using Python? nishans 1 1,019 Jan-02-2024, 10:37 AM
Last Post: khanzain
  python connect to mssql wailoonho 7 1,616 Dec-07-2023, 02:06 AM
Last Post: wailoonho
  i tried to install python for the first time today and pretty certain im being remote brianlj 2 555 Oct-03-2023, 11:15 AM
Last Post: snippsat
  Using Python to connect to an XML ? jehoshua 12 1,996 Jul-11-2023, 12:34 AM
Last Post: jehoshua
  Is there a *.bat DOS batch script to *.py Python Script converter? pstein 3 3,293 Jun-29-2023, 11:57 AM
Last Post: gologica
  PsInfo from remote computer in python susja 3 2,284 Oct-10-2022, 08:39 AM
Last Post: DeaD_EyE
  Trying to make a bot to connect on discord with Selenium Python johnsmith43 2 52,174 Mar-21-2022, 02:56 PM
Last Post: Cloudytechnical

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020