mysql.connector.errors.InterfaceError:2026(HY000)

时间:2019-03-22 07:34:10

标签: mysql python-3.x anaconda

从自制python切换到anaconda python后出现问题,问题是当我运行完全相同的代码时得到:

  

mysql.connector.errors.InterfaceError:2026(HY000):SSL连接错误:SSL_CTX_set_tmp_dh失败

这是我的代码:

import mysql.connector

mydb = mysql.connector.connect(
  host = "localhost",
  user = "root",
  passwd = "123456root",
  database = "tourists"
)

mycursor = mydb.cursor()

#mycursor.execute("CREATE DATABASE tourists")

#mycursor.execute("CREATE TABLE clients(id INT NOT NULL AUTO_INCREMENT                PRIMARY KEY,firstname VARCHAR(255), lastname VARCHAR(225), year VARCHAR(5),   room VARCHAR(2))")

mycursor.execute("ALTER TABLE clients ADD COLUMN telefon")

mycursor.execute("ALTER TABLE clients ADD COLUMN parere")

mycursor.execute("ALTER TABLE clients ADD COLUMN localitate"

预先感谢

2 个答案:

答案 0 :(得分:0)

我猜想anaconda中的mysql连接器与openssl存在一些兼容性问题。解决方案是降级openssl。

conda install openssl=1.0.2p

有关更多信息,请参见此线程:

https://github.com/ContinuumIO/anaconda-issues/issues/10646

答案 1 :(得分:0)

conn=mysql.connector.connect(host = "localhost", user = "root", passwd = "password",use_pure=True)
print(conn)
if(conn):
    print("Connection successful")
else:
    print("Connection unsuccessful")