0

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

import MySQLdb
connection = MySQLdb.connect(host = "192.168.2.205", 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/sda.py", line 3, in <module>
    connection = MySQLdb.connect(host = "192.168.2.205", user = "root", passwd = "klasikaK1", db = "myDatabase")
  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 187, in __init__
    super(Connection, self).__init__(*args, **kwargs2)
_mysql_exceptions.OperationalError: (2003, "Can't connect to MySQL server on '192.168.2.205' (111)")
Avinash Raj
  • 172,303
  • 28
  • 230
  • 274
Vrankela
  • 1,162
  • 3
  • 16
  • 39
  • 2
    post the full traceback. – Avinash Raj Jul 17 '15 at 07:32
  • @AvinashRaj I just posted the traceback – Vrankela Jul 17 '15 at 07:39
  • @AvinashRaj it was a nice guess, but that didn't solve it :( – Vrankela Jul 17 '15 at 07:48
  • Database name is correct(exist?), permission, driver(python) is right? Try non root user example "webuser", and set permission. Any root user got full permission on database, it is not nicely ! – dsgdfg Jul 17 '15 at 08:05
  • @SDilmac yes, the database name is correct and what difference does the user name have? I can access it via web browser to the /phpmyadmin. It is a test connection and db anyway. I am almoast certain I am using the correct python driver, what options do you recomend here? – Vrankela Jul 17 '15 at 08:09
  • Use non root user on mysql for any personal or web application. What is default user (mysql) of phpmyadmin? – dsgdfg Jul 17 '15 at 08:22
  • I suggest to have a look at this answer here: http://stackoverflow.com/questions/1420839/cant-connect-to-mysql-server-error-111 – Marco Jul 17 '15 at 08:27
  • Use non root user on mysql for any personal or web application. What is default user (mysql) of phpmyadmin? Please check tis: http://stackoverflow.com/questions/3266524/mysql-phpmyadmin-user-password-for-database – dsgdfg Jul 17 '15 at 08:28
  • I solved it, I just didnt set the permission to IPs outside of localhost. Thank you – Vrankela Jul 17 '15 at 11:21

0 Answers0