问题遇到的现象和发生背景
学习过程中,练习python链接数据库,服务打开了,客户端用这个账号和密码也能链接,但是还是报错
问题相关代码,请勿粘贴截图
from pymysql import *
conn = connect(host="localhost", port=3306, database="jing_dong", user="root", password="renyuanyuan", charset="utf8")
cs1 = conn.cursor()
sql = "select * from goods;"
content = cs1.execute(sql)
print(content)
cs1.close()
conn.close()
运行结果及报错内容
pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 8] nodename nor servname provided, or not known)")
Process finished with exit code 1