Ubuntu18 安装MySQL

安装MySQL过程

https://zazalu.space/2019/06/14/ubuntu18-04%E5%AE%89%E8%A3%85mysql8-0-16-Community/

使用Navicat

https://www.cnblogs.com/opsprobe/p/9126864.html

远程连接权限,1130, "Host 'xxxx' is not allowed to connect to this MySQL server"

https://blog.csdn.net/zd147896325/article/details/82427107

Mysql 解决1251 client does not support ...问题

https://blog.csdn.net/u012604745/article/details/80632860

 

插入图片,先建一张表

图片字段类型

https://blog.csdn.net/cbbbc/article/details/49024011

# -*- coding=utf-8 -*-
import pymysql
import sys

# 读取图片文件

# fp = open("test.jpg",'rb',encoding='utf-8')
fp = open("timg.jpg", 'rb')
img = fp.read()
fp.close()
# 创建连接
conn = pymysql.connect(host='192.168.3.12',
                       port=3306,
                       user='root',
                       passwd='*****',
                       db='mysql',
                       charset='utf8',
                       use_unicode=True, )
# 创建游标
cursor = conn.cursor()
# 在插入blob字段前,加一个 _binary  可以防止报警告Warning: (1300, "Invalid utf8mb4 character string: 'F9876A'")
sql = "INSERT INTO board_img VALUES  (%s, %s,_binary  %s);"
args = ('1', '3', img)
cursor.execute(sql, args)

# 提交,不然无法保存新建或者修改的数据
conn.commit()

# 关闭游标
cursor.close()
# 关闭连接
conn.close()

从MySQL读出图片

https://blog.csdn.net/pandarawen/article/details/8339414

https://www.it1352.com/1748838.html

data2 = cursor.fetchall()

file_like2 = io.BytesIO(data2[0][0])

img1=Image.open(file_like2)
img1.show()

python中查询数据库时fetchone()函数和fetchall()函数的区别

https://blog.csdn.net/qq_40625030/article/details/79722996

 

 

MySQL设计表

https://blog.csdn.net/The_Time_Runner/article/details/102815613

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值