1.昨天以为的密码错误;所以解决方法是 https://blog.csdn.net/qq_32791023/article/details/80252488 这个还蛮全的。所以要么就是不改/要么123456,这种密码忘记是没有方便快捷的“忘记密码的”
2.SyntaxError: Non-UTF-8 code starting with PyCharm出现这个错误,中文字符为乱码,就在代码最上面加上一行
# coding=gbk
3.PyCharm mysql python
# coding=gbk
import pymysql
hostName = "localhost"
userName ="root"
userPassword ="123456"
dbName = "test"
#使用connect函数连接mysql
db = pymysql.connect(hostName,userName,userPassword,dbName)
#我们需要一个游标
_cursor = db.cursor()
#编写SQL
sql="select * from imd_book"
try:
#执行SQL
_cursor.execute(sql)
#获取数据
results = _cursor.fetchall()
#循环显示数据
for row in results:
print(row[2],row[3])
except:
print('出错la');
#关闭数据库,涉及到同一个事务——同一个连接
db.close()
结果: