MySQLdb Python API: Unable to connect

M

Mondal

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:
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
File "C:\Python24\Lib\site-packages\MySQLdb\__init__.py", line 66, in

Connect
return Connection(*args, **kwargs)
File "C:\Python24\Lib\site-packages\MySQLdb\connections.py", line
134, in __init__
super(Connection, self).__init__(*args, **kwargs2)
OperationalError: (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:




Traceback (most recent call last):
File "<interactive input>", line 1, in ?
File "C:\Python24\Lib\site-packages\MySQLdb\__init__.py", line 66, in

Connect
return Connection(*args, **kwargs)
File "C:\Python24\Lib\site-packages\MySQLdb\connections.py", line
134, in __init__MyM
super(self,Connection).__init__(*args, **kwargs2)
OperationalError: (2003, "Can't connect to MySQL server on 'localhost'
(10061)")

What is happening?


Thanks in advance for any help


Regards
Mondal
 
D

Dennis Lee Bieber

So what is that - doing in the port number... So far as I know,
nothing reasonable lives on port 324...

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="localhost",
user="BestiariaCP",
#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.
--
 
N

Nicolas Kassis

Dennis said:
So what is that - doing in the port number... So far as I know,
nothing reasonable lives on port 324...
I don't see anything with 324 in there ? What do you mean ?
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="localhost",
user="BestiariaCP",
#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.
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
 
F

Fredrik Lundh

Dennis said:
A direct copy from about ten lines above.


330 minus 6 equals 324

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:
=3D'shop',port=3D330=AD6)

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

</F>
 
D

Dennis Lee Bieber

except that the - you're seeing is a soft hyphen, so most people won't
see it...
Ah, interesting... I thought Agent was pretty good at handling
quoted printable, yet it left that in (as a regular hyphen after
replying). I'd still have to wonder what a soft hyphen is doing in text
that should have been a simple cut&paste from the interactive prompt.
Implies the posting client first did word-processor style hyphenation
(in the middle of a numeric?), followed by the QP encoding putting in a
soft newline (which Agent did handle -- as the material displays as one
line to me). If the hyphen had been the last thing on the line, I may
have realized what it was.
--
 
M

Mondal

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
 
D

Dennis Lee Bieber

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.
Question #1: can you connect using the command line "mysql" utility,
or the MySQLQueryBrowser (might be an extra download, or try the Admin
tool).

Question #2: If you CAN connect with those tools, try creating a
test user with "localhost" privileges but NO password at all.

I don't recall if MySQLdb has been updated to work with the new
password algorithm used since MySQL4.1 (I think). That's why that sample
I posted had the password commented out -- I had to create a read-only
(select only) account with no password to get my CherryTemplate site
generation code to connect. I'm running 4.1.15.

There is a "use old passwords" option in the admin tool, but I had
trouble getting it to work. It is "needed for 4.0 or older clients". I'm
running the MySQLdb 1.2.0 for Python 2.3. (Just looked -- notes state
the 2.3 compatible version was built against 4.0, whereas the 2.4
version is built against 4.1.x)

Hmmm, no... that condition has a specific error message. {password
obscured -- and I just checked, I have one account that has a 4.0
password still in the user table, and I can connect to that one; root
has a 4.1 password}
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
File "E:\Plone_2\Python\lib\site-packages\MySQLdb\__init__.py", line
66, in Connect
return Connection(*args, **kwargs)
File "E:\Plone_2\Python\lib\site-packages\MySQLdb\connections.py",
line 134, in __init__
super(Connection, self).__init__(*args, **kwargs2)
OperationalError: (1251, 'Client does not support authentication
protocol requested by server; consider upgrading MySQL client')

Check the user table entry for "root", make sure it allows
"localhost".

Second -- check the configuration; you haven't turned off TCP/IP
networking (I suspect MySQLdb doesn't use named pipes).

--
 
M

Mondal

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top