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

Alain Ketterlin alain at dpt-info.u-strasbg.fr
Wed Aug 15 11:22:49 EDT 2012


Hans Mulder <hansmu at xs4all.nl> writes:

> On 15/08/12 15:30:26, nepaul wrote:
>> 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'.

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.



More information about the Python-list mailing list