python - OperationalError: (OperationalError) (2003, "Can't connect to MySQL server on '192.168.129.139' (111)") None None -


i trying create remote database using mysql on ubuntu machine running 12.04.

it has root user remote login enabled , no password.i have started server.

output of

sudo netstat -tap | grep mysql 

shows

tcp        0      0 localhost:mysql         *:*                     listen      13246/mysqld 

i have created database called nwtopology using (as mentioned root doesn't have password yet.)

 create database nwtopology  grant privileges on *.* root@192.168.129.221  flush privileges; 

from client machine runs ubuntu 12.04 use python script connect remote mysql database using sqlalchemy.

from pox.core import core import pox.openflow.libopenflow_01 of import re import datetime import time sqlalchemy import create_engine, foreignkey sqlalchemy import column, date, integer, string sqlalchemy.ext.declarative import declarative_base sqlalchemy.orm import relationship, backref sqlalchemy import create_engine sqlalchemy.orm import sessionmaker sqlalchemy.sql.expression import exists  log = core.getlogger() engine = create_engine('mysql://root@192.168.129.139/nwtopology', echo=false) base = declarative_base() session = sessionmaker(bind=engine) session = session()  class sourcetoport(base):     """"""     __tablename__ = 'source_to_port'     id = column(integer, primary_key=true)     port_no        = column(integer)     src_address    = column(string,index=true)      #-----------------------------------------     def __init__(self, src_address,port_no):         """"""         self.src_address = src_address         self.port_no     = port_no 

the create_engine() call failing following error.

pox 0.1.0 (betta) / copyright 2011-2013 james mccauley, et al. traceback (most recent call last):   file "/home/karthik/ms_thesis/pox/pox/boot.py", line 89, in do_import2     __import__(name, globals(), locals())   file "/home/karthik/ms_thesis/pox/custom/tutorial.py", line 39, in <module>     base.metadata.create_all(engine)   file "/usr/lib/python2.7/dist-packages/sqlalchemy/schema.py", line 2515, in create_all     tables=tables)   file "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 2230, in _run_visitor     conn = self.contextual_connect(close_with_result=false)   file "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 2340, in contextual_connect     self.pool.connect(),   file "/usr/lib/python2.7/dist-packages/sqlalchemy/pool.py", line 210, in connect     return _connectionfairy(self).checkout()   file "/usr/lib/python2.7/dist-packages/sqlalchemy/pool.py", line 371, in __init__     rec = self._connection_record = pool._do_get()   file "/usr/lib/python2.7/dist-packages/sqlalchemy/pool.py", line 697, in _do_get     con = self._create_connection()   file "/usr/lib/python2.7/dist-packages/sqlalchemy/pool.py", line 174, in _create_connection     return _connectionrecord(self)   file "/usr/lib/python2.7/dist-packages/sqlalchemy/pool.py", line 256, in __init__     self.connection = self.__connect()   file "/usr/lib/python2.7/dist-packages/sqlalchemy/pool.py", line 316, in __connect     connection = self.__pool._creator()   file "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/strategies.py", line 80, in connect     return dialect.connect(*cargs, **cparams)   file "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/default.py", line 280, in connect     return self.dbapi.connect(*cargs, **cparams)   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) operationalerror: (operationalerror) (2003, "can't connect mysql server on '192.168.129.139' (111)") none none 

i cannot figure out why happening?any appreciated?

looks mysql configured listen on localhost.

you can test running telnet 192.168.129.139 3306 client machine.

most probable reason - mysqld configured so.

please try follow configuration step described here:

edit /etc/mysql/my.cnf file configure mysql listen connections network hosts, change bind-address directive server's ip address. example replace 192.168.0.5 appropriate address. if there no such entry - uncomment or create new line.

bind-address            = 192.168.0.5 

then restart mysqld

sudo service mysql restart 

then test telnet or running application once again. netstat have second entry mysqld.


Comments

Popular posts from this blog

Java sticky instances of class com.mysql.jdbc.Field aggregating -