python与mysql的连接过程
1、cmd---pip3 install PyMySQL
2、>>>import pymysql
3、mysql>create database bookdb character set utf8;
4、>>>conn=pymysql.connect(host='localhost',port=3306,user='gao',passwd='123456',db='bookdb',charset='utf8')
5、>>>cur=conn.cursor()
6、>>>cur.executemany("insert into users(username,password,email) values(%s,%s,%s)",(("python","1234","py@python.com"),("python2","12345","py2@python.com"),("python3","12346","py3@python.com"),("python4","12347","py4@python.com")))
7、>>>conn.commit()
允许从任何主机连接到mysql服务器:
(创建一个表所有用户都可以看见并操作,只要给特定用户授权)
先建一个用户,然后对用户授权远程访问
https://blog.csdn.net/weixin_40079336/article/details/81395590
#先创建一个用户
create user 'gao'@'%' identified by '123123';
#再进行授权
grant all privileges on *.* to 'gao'@'%' with grant option;
python与mysql的连接过程的更多相关文章
- Python和mysql的连接
python与mysql的连接: 说明:前提是已近安装了mysql以及可视化工具(本人装的是Navicat) 1.在cmd下下载Python的第三方数据库包:pip install pymysql: ...
- Python下Mysql数据连接池——单例
# coding:utf-8 import threading import pymysql from DBUtils.PooledDB import PooledDB from app.common ...
- python selenium 测试环境的搭建及python mysql的连接
又来一篇傻瓜教程啦,防止在学习的小伙伴们走弯路. 1.python 环境搭建 python官网:https://www.python.org/downloads/ 选择最新版本python下载(如果 ...
- Python安装MySQL数据库模块
背景 折腾: [记录]使用Python操作MySQL数据库 的过程中,需要去安装MySQLdb. 下载MySQLdb 去官网: http://pypi.python.org/pypi/MySQL-py ...
- Python安装MySQLdb并连接MySQL数据库
当然了,前提是你已经安装了Python和MySQL.我的Python是2.6版本的. Python2.6的“Set”有点兼容性问题,自己照着改一下: http://sourceforge.net/fo ...
- python使用MySQLdb模块连接MySQL
1.安装驱动 目前有两个MySQL的驱动,我们可以选择其中一个进行安装: MySQL-python:是封装了MySQL C驱动的Python驱动:mysql-connector-python:是MyS ...
- python 和 mysql连接
python 和 mysql连接 虫师教程:http://www.cnblogs.com/fnng/p/3565912.html 其他教程pymysql:http://www.cnblogs.com/ ...
- Python使用Mysql过程中一些错误
Python使用Mysql过程中一些错误 ssh登录远程服务器 ssh ubuntu@xxx.xxx.xx.xx 第一:ubuntu终端中登录Mysql mysql -uroot -p 然后输入密码即 ...
- Python+Flask+MysqL的web技术建站过程
1.个人学期总结 时间过得飞快,转眼间2017年就要过去.这一年,我学习JSP和Python,哪一门都像一样新的东西,之前从来没有学习过. 这里我就用我学习过的Python和大家分享一下,我是怎么从一 ...
随机推荐
- solidity语言3
#函数类型(function type) function (<parameter types>) {internal|external(public)} [pure|constant|v ...
- shell定时采集数据到HDFS
上线的网站每天都会产生日志数据.假如有这样的需求:要求在凌晨 24 点开始操作前一天产生的日志文件,准实时上传至 HDFS 集群上. 该如何实现?实现后能否实现周期性上传需求?如何定时? Linux ...
- Tcpdump usage examples
In most cases you will need root permission to be able to capture packets on an interface. Using tcp ...
- 【Leetcode】【Easy】Merge Sorted Array
Given two sorted integer arrays A and B, merge B into A as one sorted array. Note:You may assume tha ...
- VueJS 使用i18n做国际化切换中英文
1.安装 npm install vue-i18n --save 2.创建存放语言包和i18n入口文件 a.在src下创建i18n目录 b.在src/i18n/创建i18n.js (入口) c.在s ...
- March 28 2017 Week 13 Tuesday
Never was anything great achieved without danger. 不经历风雨,又怎能见彩虹. After the rain, if there's the sunsh ...
- PCI PCI-X PCI-E介绍
1.PCI 外设互联标准(或称个人电脑接口,Personal Computer Interface),实际应用中简称PCI(Peripheral Component Interconnect),是一种 ...
- Android进阶笔记11:ListView篇之ListView性能优化
1. 首先思考一个问题ListView如何才能提高效率 ? 当convertView为空时候,用setTag()方法为每个View绑定一个存放控件的ViewHolder对象.当convertView不 ...
- Alex 的 Hadoop 菜鸟教程: 第3课 Hadoop 安装教程 - 非HA方式 (一台server)
原帖地址: http://blog.csdn.net/nsrainbow/article/details/36629741 接上一个教程:http://blog.csdn.net/nsrainbow/ ...
- [18/11/29] 继承(extends)和方法的重写(override,不是重载)
一.何为继承?(对原有类的扩充) 继承让我们更加容易实现类的扩展. 比如,我们定义了人类,再定义Boy类就只需要扩展人类即可.实现了代码的重用,不用再重新发明轮子(don’t reinvent w ...