视频1 视频21 视频41 视频61 视频文章1 视频文章21 视频文章41 视频文章61 推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37 推荐39 推荐41 推荐43 推荐45 推荐47 推荐49 关键词1 关键词101 关键词201 关键词301 关键词401 关键词501 关键词601 关键词701 关键词801 关键词901 关键词1001 关键词1101 关键词1201 关键词1301 关键词1401 关键词1501 关键词1601 关键词1701 关键词1801 关键词1901 视频扩展1 视频扩展6 视频扩展11 视频扩展16 文章1 文章201 文章401 文章601 文章801 文章1001 资讯1 资讯501 资讯1001 资讯1501 标签1 标签501 标签1001 关键词1 关键词501 关键词1001 关键词1501 专题2001
python与mysql交互会遇到的各种问题及解决方法
2020-11-27 14:21:00 责编:小采
文档


本篇文章给大家带来的内容是关于python与mysql交互会遇到的各种问题及解决方法,有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助。

开始学python 交互MySQLdb,踩了很多坑

第一个

%d format: a number is required, not str

解决方法:

# -*- coding: utf-8 -*-
import MySQLdb
try:
conn=MySQLdb.connect(host='localhost',port='3306',db='test',user='root',passwd='toor',charset='utf-8')
csl=conn.cursor()
count=csl.execute("inser into stu(stu_id,stu_name,stu_phone,stu_hometown) values('0003','kj','195832601',河北)")
print count
conn.commit()
csl.close()
conn.close()
except Exception,e:
print e.message
an integer is required (got type str)
port=3306

即可

(1129, "Host '192.168.65.1' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'")

mysql -u root -p 进入数据库

show variables like 'max_connect_errors';

查看最大连接数

set global max_connect_errors = 1000;

修改max_connect_errors的值:

(3)查看是否修改成功

> show variables like '%max_connect_errors%';

解决方法2:使用mysqladmin flush-hosts 命令清理一下hosts文件

(1)在查找到的目录下使用命令修改:mysqladmin -u xxx -p flush-hosts

或者

> flush hosts;

解决方法3:重启mysqld

也可以在重启之前,在配置文件中将该参数调大。

# vi /etc/my.cnf
max_connect_errors = 100

下载本文
显示全文
专题