0.查看当前系统版本
(base) ➜ ~ cat /etc/redhat-release CentOS Linux release 7.8.2003 (Core)
(base) ➜ ~ uname -sr Linux 3.10.0-1062.18.1.el7.x86_64
|
1.下载MySQL安装文件
根据前一步获取的系统版本选择进行下载,这里则是RH7 x86_64的版本进行下载
![image-20200609175530016](/Users/0x4154304d/Library/Application Support/typora-user-images/image-20200609175530016.png)
下载RPM Bundle版本
这里直接下载捆绑包,将所有的MySQL组件全部下载下来。然后解压文件包
2. 卸载系统附带的MySQL (不是每个用户都需要执行此步骤)
查看旧版本MySQL
这里因为我已经成功安装新版本 所以系统会显示新版本
(base) ➜ ~ rpm -qa | grep mysql mysql-community-common-8.0.20-1.el7.x86_64 mysql-community-libs-8.0.20-1.el7.x86_64 mysql-community-server-8.0.20-1.el7.x86_64 mysql-community-client-8.0.20-1.el7.x86_64
|
删除旧版本
rpm -e --nodeps xxxxxxxxx
|
3.安装MySQL
根据依赖包的关系安装顺序分别为 common->libs->client->server
rpm -ivh mysql-community-common-8.0.20-1.el7.x86_64.rpm rpm -ivh mysql-community-libs-8.0.20-1.el7.x86_64.rpm rpm -ivh mysql-community-client-8.0.20-1.el7.x86_64.rpm rpm -ivh mysql-community-server-8.0.20-1.el7.x86_64.rpm
|
4.登陆及修改密码
systemctl start mysqld.service
systemctl status mysqld.service
systemctl stop mysqld.service
|
启动MySQL后查看默认密码
(base) ➜ ~ grep 'temporary password' /var/log/mysqld.log 2020-06-09T08:28:26.111487Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: 9>Z.iNW%WF?n
|
这里的9>Z.iNW%WF?n
就是默认密码,之后登陆数据库
修改密码
mysql> alter user root@localhost identified by 'xxxxxxxxxxxxxxxxx(新密码)'; #修改完成后重新登陆验证修改成功 \q
|