MySQLdb Python API: Unable to connect

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mondal

    #1

    MySQLdb Python API: Unable to connect

    Hi,

    I am using MySQL 5.0 beta and Active Python 2.4. I have the correct
    version of MySQLdb installed. The problem is that I can't connect to
    MySQL through the Active Python interactive window.

    Here is a sample error:
    [color=blue][color=green][color=darkred]
    >>> c=MySQLdb.Conne ct(host='localh ost',user='root ',passwd='',db= 'shop',port=330 ­6)[/color][/color][/color]
    Traceback (most recent call last):
    File "<interacti ve input>", line 1, in ?
    File "C:\Python24\Li b\site-packages\MySQLd b\__init__.py", line 66, in

    Connect
    return Connection(*arg s, **kwargs)
    File "C:\Python24\Li b\site-packages\MySQLd b\connections.p y", line
    134, in __init__
    super(Connectio n, self).__init__( *args, **kwargs2)
    OperationalErro r: (2003, "Can't connect to MySQL server on 'localhost'
    (10061)")

    Please look at the penultimate line again. Here the self argument is
    placed second to Connection argument. So I reversed their position. But
    the problem persists.


    Here is a sample:


    [color=blue][color=green][color=darkred]
    >>> c=MySQLdb.Conne ct(host='localh ost',user='root ',passwd='',db= 'shop',port=330 ­6)[/color][/color][/color]


    Traceback (most recent call last):
    File "<interacti ve input>", line 1, in ?
    File "C:\Python24\Li b\site-packages\MySQLd b\__init__.py", line 66, in

    Connect
    return Connection(*arg s, **kwargs)
    File "C:\Python24\Li b\site-packages\MySQLd b\connections.p y", line
    134, in __init__MyM
    super(self,Conn ection).__init_ _(*args, **kwargs2)
    OperationalErro r: (2003, "Can't connect to MySQL server on 'localhost'
    (10061)")

    What is happening?


    Thanks in advance for any help


    Regards
    Mondal

  • Nicolas Kassis

    #2
    Re: MySQLdb Python API: Unable to connect

    Dennis Lee Bieber wrote:
    [color=blue]
    >On 26 Dec 2005 21:39:11 -0800, "Mondal" <msmondal@gmail .com> declaimed
    >the following in comp.lang.pytho n:
    >
    >
    >[color=green][color=darkred]
    >>>>>c=MySQLdb. Connect(host='l ocalhost',user= 'root',passwd=' ',db='shop',por t=330­6)
    >>>>>
    >>>>>[/color][/color]
    >
    > So what is that - doing in the port number... So far as I know,
    >nothing reasonable lives on port 324...
    >
    >
    >[/color]
    I don't see anything with 324 in there ? What do you mean ?
    [color=blue]
    > If that is supposed to be the standard MySQL port, just leave it
    >off... Granted, I'm not running 5.x... (and I'm behind both a router
    >firewall and a software firewall AND MySQL's own authorization scheme,
    >so the user/password won't do anyone any good at getting into my system)
    >
    > myDB = MySQLdb.connect (host="localhos t",
    > user="Bestiaria CP",
    > #passwd="web-asst",
    > db="bestiaria" )
    >
    > Note the lack of a port number specification. The default port for
    >MySQL is 3306; if your server is running on the default, you don't need
    >to specify it. Error 10061 is the generic Windows socket "connection
    >refused" -- since I doubt you have anything on port 324, that is to be
    >expected.
    >
    >[/color]
    Just to make sure, ( Not trying to be a smart ass) are you sure the
    database is running ? That seems like the most obvious thing.

    Nic

    Comment

    • Fredrik Lundh

      #3
      Re: MySQLdb Python API: Unable to connect

      Dennis Lee Bieber wrote:
      [color=blue][color=green]
      > > I don't see anything with 324 in there ? What do you mean ?
      > >[/color]
      > A direct copy from about ten lines above.
      >[color=green][color=darkred]
      > > >>>>>c=MySQLdb. Connect(host='l ocalhost',user= 'root',passwd=' ',db='shop',por t=330­6)[/color][/color]
      >
      > 330 minus 6 equals 324[/color]

      except that the - you're seeing is a soft hyphen, so most people won't
      see it...

      here's an excerpt from the message source:
      [color=blue][color=green][color=darkred]
      > >>> c=3DMySQLdb.Con nect(host=3D'lo calhost',user=3 D'root',passwd= 3D'',db=[/color][/color][/color]
      =3D'shop',port= 3D330=AD6)

      =3D is an equal sign
      =AD is a soft hyphen

      </F>



      Comment

      • Mondal

        #4
        Re: MySQLdb Python API: Unable to connect

        Hi all,

        Frederik is right. The hyphen in the port number was inserted when i
        copied and pasted the error message. i used the port number 3306 (three
        three zero six).

        I am sorry about this, but i forgot to mention that my os is Windows
        XP. MySQL is installed on my machine itself. Its using port 3306.
        'Root' is the only user.

        I have tried to connect by omitting the port argument.I have tried by
        removing the password also. And I do take care to start an instance of
        the server before trying to connect to it.

        But I keep getting the same error message.

        I hope someone can enlighten me

        Regards
        Mondal

        Comment

        • Mondal

          #5
          Re: MySQLdb Python API: Unable to connect

          Hi,

          First thanks to all of you for helping.

          It seems there was some error in my instance configuration or
          something.

          As a last resort I unistalled MySQL and then reinstalled in another
          drive. And bingo everything is working fine. I am able to connect
          through Python API, too.

          I copied the old data directory to the new data folder. So my data is
          also intact.

          Posted just to inform all

          *Cheers*

          Regards
          Mondal

          Comment

          Working...