_mysql_exceptions.OperationalError: (2005, "Unknown MySQL server host

N

nepaul

The code:
import MySQLDB
strCmd = "user = 'root', passwd = '123456', db = 'test', host = 'localhost'"



_mysql_exceptions.OperationalError: (2005, "Unknown MySQL server host 'user = 'root', passwd = '123456', db = 'test', host = 'localhost'' (11004)")
 
M

Mark Lawrence

The code:
import MySQLDB
strCmd = "user = 'root', passwd = '123456', db = 'test', host = 'localhost'"

_mysql_exceptions.OperationalError: (2005, "Unknown MySQL server host 'user = 'root', passwd = '123456', db = 'test', host = 'localhost'' (11004)")

My highly paid team of consultants suggest that you're trying to connect
to a MySQL server host that doesn't exist. However I'm sure that people
on this list with more knowledge of MySQLDB than my consultants will be
able to give you more detailed data.
 
N

nepaul

在 2012å¹´8月15日星期三UTC+8下åˆ10æ—¶23分24秒,Mark Lawrence写é“:
My highly paid team of consultants suggest that you're trying to connect

to a MySQL server host that doesn't exist. However I'm sure that people

on this list with more knowledge of MySQLDB than my consultants will be

able to give you more detailed data.



--

Cheers.



Mark Lawrence.

if i use MySQLdb.connect(strCmd) -> wrong, but if use MySQLdb.connect(user = 'root', passwd = '123456', db = 'test', host = 'localhost'),it work. and the strCmd is read from a xml file.
 
N

nepaul

在 2012å¹´8月15日星期三UTC+8下åˆ10æ—¶23分24秒,Mark Lawrence写é“:
My highly paid team of consultants suggest that you're trying to connect

to a MySQL server host that doesn't exist. However I'm sure that people

on this list with more knowledge of MySQLDB than my consultants will be

able to give you more detailed data.



--

Cheers.



Mark Lawrence.

if i use MySQLdb.connect(strCmd) -> wrong, but if use MySQLdb.connect(user = 'root', passwd = '123456', db = 'test', host = 'localhost'),it work. and the strCmd is read from a xml file.
 
H

Hans Mulder

The code:
import MySQLDB
strCmd = "user = 'root', passwd = '123456', db = 'test', host = 'localhost'"



_mysql_exceptions.OperationalError: (2005, "Unknown MySQL server host 'user = 'root',
passwd = '123456', db = 'test', host = 'localhost'' (11004)")

This message means that the MySQL connector cannot find 'localhost'.
That's odd, since localhost should be your own computer.

Which OS are you using? Is TCP/IP installed and enabled?

Can you find an entry for 'localhost' in your /etc/hosts file?
Can you ping it?

What happens if you try host='127.0.0.1'?

Incidentally, connecting as 'root' for non-administrative purposes is
considered bad practice. Consider creating a 'test' account that only
has access to the 'test' database.

Oh, and I hope that '123456' is not really the password for 'root'.


Hope this helps,

-- HansM
 
A

Alain Ketterlin

Hans Mulder said:
This message means that the MySQL connector cannot find 'localhost'.

No, it means that connect received a single string "user = 'root'..."
instead of a set of individual keyword parameters, and took the whole
string to be the name of the host (its first parameter). Of course,
there is no host with such a name.

The solution is to parse the string into individual values, and pass
these in the correct order.

-- Alain.
 
N

nepaul

在 2012å¹´8月15日星期三UTC+8下åˆ11æ—¶22分49秒,Alain Ketterlin写é“:
No, it means that connect received a single string "user = 'root'..."

instead of a set of individual keyword parameters, and took the whole

string to be the name of the host (its first parameter). Of course,

there is no host with such a name.



The solution is to parse the string into individual values, and pass

these in the correct order.



-- Alain.

Yeah!Great!Thanks!
 
D

Dennis Lee Bieber

No, it means that connect received a single string "user = 'root'..."
instead of a set of individual keyword parameters, and took the whole
string to be the name of the host (its first parameter). Of course,
there is no host with such a name.

The solution is to parse the string into individual values, and pass
these in the correct order.

MySQLdb code itself recommends to always use keyword parameters, so
the order shouldn't be significant... (and when one sees the list of
optional keywords, using null commas to space positional arguments would
be insane)

Parsing that string into separate fields (preferably a dictionary so
**conectitems could be used) OTOH is critical.
 
N

nepaul

在 2012å¹´8月16日星期四UTC+8上åˆ12æ—¶58分07秒,Dennis Lee Bieber写é“:
 
N

nepaul

在 2012å¹´8月16日星期四UTC+8上åˆ12æ—¶58分07秒,Dennis Lee Bieber写é“:
 

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

Similar Threads

MySQLdb not playing nice with unicode 1
Login to MYSQL 1
MySQL: AttributeError: cursor 1
Python, mySQL and password 0
Cannot connect to Mysql database 4
mysqldb SELECT COUNT reurns 1 5
mySQL problems 2
MySQLdb 2

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top