本文介绍了mysql.connector.errors.InterfaceError:2026(HY000)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从自制python切换到anaconda python之后,以前可以运行的代码现在出现以下错误:

After switching from homebrew python to anaconda python, code that worked previously, now gets the following error:

这是我的代码:

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"

推荐答案

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

这篇关于mysql.connector.errors.InterfaceError:2026(HY000)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-10 22:00