_mysql_exceptions.OperationalError: (2005, "Unknown MySQL server host
nepaul
xs.nepaul at gmail.com
Wed Aug 15 12:50:34 EDT 2012
在 2012年8月15日星期三UTC+8下午11时22分49秒,Alain Ketterlin写道:
> 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.
Yeah!Great!Thanks!
More information about the Python-list
mailing list