大数跨境
0
0

Windows系统下,不卸载原有MySQL,直接安装MySQL8.0新版本!

Windows系统下,不卸载原有MySQL,直接安装MySQL8.0新版本! 数据分析与统计学之美
2022-03-17
0
大家好,我是黄同学🚀
今天讲解:Windows系统下,如何不卸载原有MySQL,安装MySQL8.0新版本!录制视频如下:
首先,来看看下文的赠书活动!
4000字肝货,详解tkinter图形化界面"制作"流程!
戳上方连接,参与赠书活动!
👆👆👆

下载zip安装包

下载地址:
 
https://dev.mysql.com/downloads/mysql/
为了下载快点,我找了个别人已经上传的按百度云下载地址:
 
链接:https://pan.baidu.com/s/1vORXjeap7US2bdWDZA6pNQ
提取码:cu79
下载完成后,解压压缩包,进入压缩的目录,新建文本文件my.ini。假设你解压出来的目录为E:\Program Files\mysql-8.0.19-winx64,其中my.ini内容如下:
 
[mysqld]
# 设置3306端口
port=3306
# 设置mysql的安装目录
basedir=E:\Program Files\mysql-8.0.19-winx64
# 设置mysql数据库的数据的存放目录
datadir=E:\Program Files\mysql-8.0.19-winx64\data
# 允许最大连接数
max_connections=200
# 允许连接失败的次数。这是为了防止有人从该主机试图攻击数据库系统
max_connect_errors=10
# 服务端使用的字符集默认为UTF8
character-set-server=UTF8MB4
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
# 默认使用“mysql_native_password”插件认证
default_authentication_plugin=mysql_native_password
[mysql]
# 设置mysql客户端默认字符集
default-character-set=UTF8MB4
[client]
# 设置mysql客户端连接服务端时默认使用的端口
port=3306
default-character-set=UTF8MB4

初始化数据库

在MySQL安装目录的bin目录执行命令:
 
mysqld --initialize --console
此时,我的win7系统报错:
解决方案:
 
去百度下载一个vcruntime140_1.dll放入%windir%\system32\目录中。

我使用的下载地址:https://www.jb51.net/dll/vcruntime140_1.dll.html

%windir%\system32\在我的系统中表示C:\Windows\System32
或者在vcruntime140_1.dll所在目录执行:
 
#建议将vcruntime140_1.dll复制粘贴到C:\Windows\System32即可。
regsvr32 vcruntime140_1.dll
再次执行上述命令后:
 
E:\Program Files\mysql-8.0.19-winx64\bin>mysqld --initialize --console
2020-06-06T16:34:34.062007Z 0 [System] [MY-013169] [Server] E:\Program Files\mys
ql-8.0.19-winx64\bin\mysqld.exe (mysqld 8.0.19) initializing of server in progre
ss as process 7816
2020-06-06T16:34:37.513202Z 5 [Note] [MY-010454] [Server] A temporary password i
s generated for root@localhost: /rfMQ+bGi22z
表示初始化成功。
 
注意:我这里生成的临时密码是/rfMQ+bGi22z,下文会使用到。

登陆mysql数据库

启动mysql服务端,需要另外启动一个命令后,执行mysqld:
 
E:\Program Files\mysql-8.0.19-winx64\bin>mysqld
就如上图一样,让这个命令行一直后台挂着,mysql的服务进程占用着它,不能关闭,关闭后mysql的服务进程也会跟着被关闭。
再用mysql客户端登陆后,顺利登陆:
 
E:\Program Files\mysql-8.0.19-winx64\bin>mysql -uroot -p/rfMQ+bGi22z
mysql: [Warning] Using a password on the command line interface can be insecure.

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.19

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>
修改密码为123456:
 
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '1
23456'
;
Query OK, 0 rows affected (0.01 sec)

mysql>

注册/删除mysql服务

经过上述操作mysql8.0已经可以正常使用,但有朋友可能会嫌弃启动mysql服务居然需要占用一个命令行,现在我们将mysql服务端注册为系统服务解决这个问题。
在MySQL安装目录的bin目录执行命令:
 
E:\Program Files\mysql-8.0.19-winx64\bin>mysqld --install mysql8.0
Service successfully installed.
mysql8.0可以改为其他你喜欢的服务的名字。
注册成功后,任务管理器上可以看到服务的名字:
只需要右键启动服务,mysql8.0就可以正常使用了。
然后mysql客户端就可以使用新密码正常的登陆了:
 
E:\Program Files\mysql-8.0.19-winx64\bin>mysql -uroot -p123456
mysql: [Warning] Using a password on the command line interface can be insecure.

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.19 MySQL Community Server - GPL

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>
如果读者以后向我一样习惯了命令行,也可以删除服务:
 
#mysql8.0是你要删除的服务名称
sc delete mysql8.0 -remove

推荐阅读    点击标题可跳转

0. 深度对比Python4大文件/文件夹处理库!
1. Python快速实现分列转到行!
2. 对比学习12款Python数据可视化库!
3. 如何用Python分析股票收益率?
4. pprint漂亮的打印,强烈推荐大家学习这个库!
5. 数据分析方法论,大总结!
6. 有了这款Python神器,新手也会调试代码!
7. Pandas与openpyxl库的 "完美" 融合!
8. Python提取PDF简历中的信息,写入Excel
9. Linux系列:完美收官,一共22个课时!
10. Python操作MySQL数据库!
11. 一个「神奇」的Python库,99%的人都爱!

【声明】内容源于网络
0
0
数据分析与统计学之美
免费领10w字"Python知识手册",共400页,后台回复“十万”领取!
内容 1080
粉丝 0
数据分析与统计学之美 免费领10w字"Python知识手册",共400页,后台回复“十万”领取!
总阅读0
粉丝0
内容1.1k