我有一个XAMPP DB,我正试图通过Red Hat Linux服务器上的mysql.connector连接到它。问题是数据库只能从/opt/lampp/bin/mysql访问。我找不到使用mysql.connector模块指定路径的方法。
我的代码是:
import mysql.connector
config = {
'user': 'user',
'password': '*****',
'host': '127.0.0.1',
'database': 'test',
'raise_on_warnings': True,
}
cnx = mysql.connector.connect(**config)
cursor = cnx.cursor()
query = "show columns from Table1"
cursor.execute(query)
lst = []
for line in cursor:
lst.append(line[0])
query2 = "select * from Table1 limit 5"
lst2 = []
cursor.execute(query2)
for line in cursor:
lst2.append(dict(zip(lst, line)))
print(lst2)
cnx.close()现在,我在运行mysql.connector.errors.InterfaceError: Failed parsing handshake; end byte not present in buffer时收到一个错误,但我假设这可能是因为我没有指定数据库的路径。
谢谢
发布于 2014-12-03 22:40:58
我正在寻找证据表明这个问题与MySQL版本5.5.8有关。您运行的是什么版本的MySQL?
https://stackoverflow.com/questions/26977618
复制相似问题