前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >python与mysql交互中的各种坑

python与mysql交互中的各种坑

作者头像
py3study
发布2020-01-19 15:55:40
6440
发布2020-01-19 15:55:40
举报
文章被收录于专栏:python3python3

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

第一个

%d format: a number is required, not str

参照以下博客:

https://blog.csdn.net/u011878172/article/details/72599120

# -*- 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','19564832601',河北)")

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

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2019-03-16 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
云数据库 SQL Server
腾讯云数据库 SQL Server (TencentDB for SQL Server)是业界最常用的商用数据库之一,对基于 Windows 架构的应用程序具有完美的支持。TencentDB for SQL Server 拥有微软正版授权,可持续为用户提供最新的功能,避免未授权使用软件的风险。具有即开即用、稳定可靠、安全运行、弹性扩缩等特点。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档