首先下载最新的MySQL 5.7.17 Community 压缩版 for Windows 64-bit:
官方下载地址:http://dev.mysql.com/downloads/mysql/
然后解压到安装目录(如C:\Prog\MySQL\)。接下来复制my-default.ini为my.ini,修改my.ini如下:
[mysql] default-character-set=utf8mb4 [mysqld] basedir = C:\Prog\MySQL datadir = C:\Prog\MySQL\data port = 3306 max_connections=200 character-set-server=utf8mb4 collation-server=utf8mb4_general_ci default-storage-engine=INNODB join_buffer_size = 128M sort_buffer_size = 2M read_rnd_buffer_size = 2M sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
之后用“管理员身份”打开cmd——“管理员身份”这很重要,进入安装目录安装MySQL服务:
C:\Prog\MySQL\bin>mysqld install Service successfully installed.
然后启动MySQL服务:
net start mysql
刚开始以为就这么简单,可是幺蛾子的却报错了:
如果是通过Windows系统的“服务”启动,则提示:
问题出得实在是心塞不已,查了许久,原来是:
If you installed MySQL using the Noinstall package, you may need to initialize the data directory:
- Windows distributions prior to MySQL 5.7.7 include a data directory with a set of preinitialized accounts in the mysql database.
- As of 5.7.7, Windows installation operations performed using the Noinstall package do not include a data directory. To initialize the data directory, use the instructions at Section 2.10.1.1, “Initializing the Data Directory Manually Using mysqld”.
具体可参考这两个链接:
2.3.5.4 Initializing the Data Directory
2.10.1.1 Initializing the Data Directory Manually Using mysqld
原因找到了,那我们来手动Initialize Data Directory一下啊:
mysqld --defaults-file=C:\Prog\MySQL\my.ini --initialize-insecure
然后依次:
net start mysql mysql -u root -p
熟悉的mysql>应该就出来了。
希望对遇到类似坑的人有所帮助,究其原因就是5.7.7及以后的压缩包版本,更改为需要手动Initialize Data Directory了。
技无一招鲜,坑要一路填。
我的环境:
- Windows 10 64-bit
- MySQL Community Server 5.7.17 for Windows (x86, 64-bit), ZIP Archive
(分割线,以上MySQL 5.7.17就算安装完毕了。)
最后手贱,搞个SQLAlchemy测试MySQL:
"""SQLAlchemy操作MySQL测试""" from sqlalchemy import create_engine, Table, Column, Integer, MetaData from sqlalchemy.dialects.mysql import CHAR from sqlalchemy.sql import select ENGINE = create_engine('mysql+pymysql://root:@127.0.0.1:3306/test"Incorrect string value: '\xD6\xD0\xB9\xFA\xB1\xEA...' for column 'VARIABLE_VALUE' at row 480")这是怎么回事呢?要说各种字符集设置都检查n次,应该没啥问题了......
无数次思考、试验中,发现了啥?发现了啥?发现只要show variables like '%charac%';一下,就会出来一个告警!
再来看看这个这个Warning:
不正是它吗?MySQL的Bug莫不是?!OMG!
好吧!重回MySQL 5.6.35!
告警不见了!
接着重新建库、建表,测试程序:
这下OK了,最终还是兜了一圈回到了MySQL 5.6.35。
安静地写Python,没人吵,也不像前端撕来撕去的——岁月静好、Python静好。
最后赞一下Visual Studio Code:
总结
以上就是这篇文章的全部内容了,希望自己的一些经验能帮到同样遇到这些问题的朋友们,如果有疑问大家也可以留言交流。
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
更新日志
- 曾轶可.2011-一只猫的旅行【天娱传媒】【WAV+CUE】
- 黑神话悟空上品狼刺客精魄获取方法一览|上品狼刺客精魄收集攻略
- 视觉小说《神椿市建设中REGENERATE》将于2025年2月20日发售
- 黑神话悟空上品鼠弩手精魄获取方法一览|上品鼠弩手精魄收集攻略
- 中国音乐地图听见世界非物质文化遗产《非遗HQCD》wav
- 中国民乐合奏作品集《华夏之音HQ》头版限量编号[WAV+CUE]
- [电影原声带]黎允文《天将雄师》[FLAC+CUE]
- 曝NS继任机型已进入量产阶段:已花了30亿日元
- 不是Switch2?曝《马里奥惊奇》NS捆绑包即将公开
- 暖心任天堂!网友Switch维修返还时贴纸被完好保留
- 《国语老歌 经典对唱情歌 2CD》[WAV/分轨][1.1GB]
- 《刀郎 翻唱精选华语专辑 披着羊皮的狼 》[WAV+CUE][430MB]
- 《真的田震 中国乐坛红极一时的歌者 精品集》[WAV+CUE][300MB]
- 群星.1995-新滚石九大天王之情歌大全【滚石】【WAV+CUE】
- 群星.1993-滚石九大天王十二出好戏·纵夏欢唱【滚石】【WAV+CUE】