mysql.connector.errors.DatabaseError:2003(HY000):无法连接到'localhost'上的MySQL服务器(111)

时间:2019-12-12 05:15:41

标签: python python-3.x mysql-python

我正在尝试从users表中选择所有记录。此代码在本地正常工作,但显示服务器错误。

代码如下:

import mysql.connector

mydb = mysql.connector.connect(
  host="localhost",
  user="yourusername",
  passwd="yourpassword",
  database="mydatabase"
)

mycursor = mydb.cursor()

mycursor.execute("SELECT * FROM customers")

myresult = mycursor.fetchall()

for x in myresult:
  print(x)    

错误:

error message from terminal SSH at my server

0 个答案:

没有答案