python 爬虫开发环境笔记

一、Mysql
win10环境:
1、解决mysql登陆
之前装过appserv里面包含了mysql,但是忘记了root密码。
解决:
5.7版本下的mysql数据库password字段改成了authentication_string
采样网上通用方案:
在命令行输入:mysqld -nt –skip-grant-tables
重启以管理员身份运行一个cmd,输入:mysql -uroot -p,Enter进入数据库。
mysql> select user,authentication_string from user; //查询,可看到加密后的密码,据说是以MYSQLSHA1方式加密
mysql> update mysql.user set authentication_string=password(‘*‘) where user=’*‘; //修改
mysql> flush privileges; #立即生效
>mysql -u * -p //登陆
2、可视化工具:mysql-front
3、安装pymysql

pip3 install pymysql<

测试代码:

import pymysql
conn=pymysql.connect(host="localhost",user='root',password='123456',port=3306,db='mysql')
cursor =conn.cursor()
cursor.execute('select * from db')
cursor.fetchone() #用于获取db第一条数据

测试时把文件命名为pymysql模块名导致出现AttributeError: module ‘pymysql’ has no attribute ‘connect’错误。
二、安装redis
下载地址:https://github.com/MSOpenTech/redis/releases
可视化工具:https://github.com/uglide/RedisDesktopManager
控制台启动服务:redis-server.exe redis.windows.conf

猜你喜欢

转载自blog.csdn.net/linxubin321/article/details/79685184