MySQLdb connection problems

后端 未结 7 1090
逝去的感伤
逝去的感伤 2020-12-30 05:37

I\'m having trouble with the MySQLdb module.

db = MySQLdb.connect(
    host = \'localhost\', 
    user = \'root\', 
    passwd = \'\', 
    db = \'testdb\',          


        
7条回答
  •  渐次进展
    2020-12-30 06:17

    As far as I can tell, the python connector can ONLY connect to mysql through a internet socket: unix sockets (the default for the command line client) is not supported.

    In the CLI client, when you say "-h localhost", it actually interprets localhost as "Oh, localhost? I'll just connect to the unix socket instead", rather than the internet localhost socket.

    Ie, the mysql CLI client is doing something magical, and the Python connector is doing something "consistent, but restrictive".

    Choose your poison. (Pun not intended ;) )

提交回复
热议问题