我已经为Python安装了最新的mysql连接器以连接MySQL Shell。当我尝试使用Python连接MySQL Shell时出现以下错误,
>>> import mysqlx
>>> mysqlx.get_session("mysqlx://root:<passsword>@localhost:3306/mySchema")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python3.3/site-packages/mysqlx/__init__.py", line 193, in get_session
return XSession(settings)
File "/usr/lib64/python3.3/site-packages/mysqlx/connection.py", line 464, in __init__
self._connection.connect()
File "/usr/lib64/python3.3/site-packages/mysqlx/connection.py", line 328, in connect
return super(XConnection, self).connect()
File "/usr/lib64/python3.3/site-packages/mysqlx/connection.py", line 160, in connect
self._handle_capabilities()
File "/usr/lib64/python3.3/site-packages/mysqlx/connection.py", line 164, in _handle_capabilities
data = self.protocol.get_capabilites().capabilities
File "/usr/lib64/python3.3/site-packages/mysqlx/protocol.py", line 88, in get_capabilites
return self._reader.read_message()
File "/usr/lib64/python3.3/site-packages/mysqlx/protocol.py", line 56, in read_message
return self._read_message()
File "/usr/lib64/python3.3/site-packages/mysqlx/protocol.py", line 62, in _read_message
raise ProgrammingError("The connected server does not have the "
mysqlx.errors.ProgrammingError: The connected server does not have the MySQL X protocol plugin enabled
>>>
我确定X插件已启用,因为我能够使用mysqlsh读取,写入,删除集合。不知道为什么会出现此错误,任何帮助建议都会对我有所帮助。
答案 0 :(得分:2)
您应该连接到X协议端口33060. 3306是一个经典协议。