MySQL Connector / Python InterfaceError:“仅在特定主机上解析EOF数据包失败”

时间:2016-06-23 15:54:56

标签: python mysql python-2.7 mysql-connector mysql-connector-python

为了序言,我意识到这个问题已经被问到before,但是没有达到任何解决方案。希望这两年可能对理解这个问题有所帮助。

我正在尝试解决我看到此错误的问题 mysql.connector.errors.InterfaceError: Failed parsing EOF packet.

这是完整的链条:

Python 2.7.10 (default, Oct 23 2015, 19:19:21) 
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import mysql.connector as connector
>>> sql = connector.connect(host='remote_host', user='user', password='pw', database='db')
>>> cursor = sql.cursor()
>>> sql.is_connected()
True
>>> cursor.execute("select * from associations")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Python/2.7/site-packages/mysql/connector/cursor.py", line 515, in execute
    self._handle_result(self._connection.cmd_query(stmt))
  File "/Library/Python/2.7/site-packages/mysql/connector/connection.py", line 488, in cmd_query
    result = self._handle_result(self._send_cmd(ServerCmd.QUERY, query))
  File "/Library/Python/2.7/site-packages/mysql/connector/connection.py", line 407, in _handle_result
    eof = self._handle_eof(self._socket.recv())
  File "/Library/Python/2.7/site-packages/mysql/connector/connection.py", line 344, in _handle_eof
    eof = self._protocol.parse_eof(packet)
  File "/Library/Python/2.7/site-packages/mysql/connector/protocol.py", line 269, in parse_eof
    raise errors.InterfaceError(err_msg)
mysql.connector.errors.InterfaceError: Failed parsing EOF packet.

奇怪的是,我也有一个本地数据库设置完全相同的结构,具有相同的信息,并运行相同的命令串工作正常。我的本地服务器版本为5.7.12 MySQL Community Server (GPL),而我尝试连接的远程服务器为4.1.22-log

从Python / Connector手册:

Connector/Python does not support the old MySQL Server authentication methods, which means that MySQL versions prior to 4.1 will not work.

“之前”是否包含或排除4.1?如果它排除了,任何可能出错的想法?​​

1 个答案:

答案 0 :(得分:0)

从未找到过针对mysql.connector的解决方案,但我发现了一个不同的连接器 - PyMySQL,它完美地工作。甚至不用改变语法。