How to configure MySql db module in order to connect to a remote server?

I am trying to make a query with the following code:

import MySQLdb
connection = MySQLdb.connect(host = "", user = "root", passwd = "klasikaK1", db = "myDatabase")

as you can see I am targeting another machine inside the local network. I have other type of application (.war project) where the connection works, with the provided user and pass. So the remote machine’s port is open and working. I just cant get my python script to do a query this way.

The error i get is something along the lines of “cannot connect to db”

I am developing this python script in Ubuntu 14.

EDIT1 Here is the full traceback:

Traceback (most recent call last):
  File "/home/devf13/", line 3, in <module>
    connection = MySQLdb.connect(host = "", user = "root", passwd = "klasikaK1", db = "myDatabase")
  File "/usr/lib/python2.7/dist-packages/MySQLdb/", line 81, in Connect
    return Connection(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/MySQLdb/", line 187, in __init__
    super(Connection, self).__init__(*args, **kwargs2)
_mysql_exceptions.OperationalError: (2003, "Can't connect to MySQL server on '' (111)")

Source: ubuntu

Leave a Reply