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

Discussion in 'Python' started by nepaul, Aug 15, 2012.

  1. nepaul

    nepaul Guest

    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)")
     
    nepaul, Aug 15, 2012
    #1
    1. Advertising

  2. Re: _mysql_exceptions.OperationalError: (2005, "Unknown MySQL serverhost

    On 15/08/2012 14:30, 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)")
    >


    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.
     
    Mark Lawrence, Aug 15, 2012
    #2
    1. Advertising

  3. nepaul

    nepaul Guest

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

    在 2012å¹´8月15日星期三UTC+8下åˆ10æ—¶23分24秒,Mark Lawrence写é“:
    > On 15/08/2012 14:30, 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)")

    >
    > >

    >
    >
    >
    > 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.
     
    nepaul, Aug 15, 2012
    #3
  4. nepaul

    nepaul Guest

    在 2012å¹´8月15日星期三UTC+8下åˆ10æ—¶23分24秒,Mark Lawrence写é“:
    > On 15/08/2012 14:30, 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)")

    >
    > >

    >
    >
    >
    > 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.
     
    nepaul, Aug 15, 2012
    #4
  5. nepaul

    Hans Mulder Guest

    Re: _mysql_exceptions.OperationalError: (2005, "Unknown MySQL serverhost

    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'.
    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
     
    Hans Mulder, Aug 15, 2012
    #5
  6. Hans Mulder <> 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.
     
    Alain Ketterlin, Aug 15, 2012
    #6
  7. nepaul

    nepaul Guest

    在 2012å¹´8月15日星期三UTC+8下åˆ11æ—¶22分49秒,Alain Ketterlin写é“:
    > Hans Mulder <> 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!
     
    nepaul, Aug 15, 2012
    #7
  8. Re: _mysql_exceptions.OperationalError: (2005,"Unknown MySQL server host

    On Wed, 15 Aug 2012 17:22:49 +0200, Alain Ketterlin
    <-strasbg.fr> declaimed the following in
    gmane.comp.python.general:

    > Hans Mulder <> 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.


    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.

    --
    Wulfraed Dennis Lee Bieber AF6VN
    HTTP://wlfraed.home.netcom.com/
     
    Dennis Lee Bieber, Aug 15, 2012
    #8
  9. nepaul

    nepaul Guest

    在 2012å¹´8月16日星期四UTC+8上åˆ12æ—¶58分07秒,Dennis Lee Bieber写é“:
    > On Wed, 15 Aug 2012 17:22:49 +0200, Alain Ketterlin
    >
    > <-strasbg.fr> declaimed the following in
    >
    > gmane.comp.python.general:
    >
    >
    >
    > > Hans Mulder <> writes:

    >
    > >

    >

    Rightï¼
    > > > 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.

    >
    >
    >
    > 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.
    >
    >
    >
    > --
    >
    > Wulfraed Dennis Lee Bieber AF6VN
    >
    > HTTP://wlfraed.home.netcom.com/
     
    nepaul, Aug 16, 2012
    #9
  10. nepaul

    nepaul Guest

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

    在 2012å¹´8月16日星期四UTC+8上åˆ12æ—¶58分07秒,Dennis Lee Bieber写é“:
    > On Wed, 15 Aug 2012 17:22:49 +0200, Alain Ketterlin
    >
    > <-strasbg.fr> declaimed the following in
    >
    > gmane.comp.python.general:
    >
    >
    >
    > > Hans Mulder <> writes:

    >
    > >

    >

    Rightï¼
    > > > 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.

    >
    >
    >
    > 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.
    >
    >
    >
    > --
    >
    > Wulfraed Dennis Lee Bieber AF6VN
    >
    > HTTP://wlfraed.home.netcom.com/
     
    nepaul, Aug 16, 2012
    #10
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. F. GEIGER
    Replies:
    1
    Views:
    652
    Gerhard Haering
    May 19, 2005
  2. Filipe Sousa
    Replies:
    2
    Views:
    746
    Filipe Sousa
    Sep 6, 2007
  3. Bob
    Replies:
    2
    Views:
    747
    Jeffrey Froman
    Jan 18, 2008
  4. Hexade
    Replies:
    2
    Views:
    4,454
    Hexade
    Apr 13, 2008
  5. Gabriel Rossetti
    Replies:
    4
    Views:
    1,499
    John Machin
    Jun 17, 2009
Loading...

Share This Page