安装Mysql 8.0安装源
[root@db ~]# sudo rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
获取https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
警告:/var/tmp/rpm-tmp.V7gbUf: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
准备中… ################################# [100%]
正在升级/安装…
1:mysql80-community-release-el7-3 ################################# [100%]
安装MySQL8.0
[root@db ~]# sudo yum --enablerepo=mysql80-community install mysql-community-server
已加载插件:fastestmirror, langpacks Loading mirror speeds from cached
hostfile * base: mirrors.aliyun.com * epel:
mirrors.tuna.tsinghua.edu.cn * extras: mirrors.aliyun.com * updates:
mirrors.aliyun.com mysql-connectors-community
| 2.6 kB 00:00:00 mysql-tools-community
| 2.6 kB 00:00:00 mysql80-community
| 2.6 kB 00:00:00 (1/3):
mysql-connectors-community/x86_64/primary_db
| 83 kB 00:00:01 (2/3): mysql-tools-community/x86_64/primary_db
| 91 kB 00:00:01 (3/3): mysql80-community/x86_64/primary_db
| 177 kB 00:00:01 正在解决依赖关系
–> 正在检查事务
—> 软件包 mysql-community-server.x86_64.0.8.0.26-1.el7 将被 安装
–> 正在处理依赖关系 mysql-community-common(x86-64) = 8.0.26-1.el7,它被软件包 mysql-community-server-8.0.26-1.el7.x86_64 需要
–> 正在处理依赖关系 mysql-community-client(x86-64) >= 8.0.11,它被软件包 mysql-community-server-8.0.26-1.el7.x86_64 需要
–> 正在检查事务
—> 软件包 mysql-community-client.x86_64.0.8.0.26-1.el7 将被 安装
–> 正在处理依赖关系 mysql-community-client-plugins = 8.0.26-1.el7,它被软件包 mysql-community-client-8.0.26-1.el7.x86_64 需要
–> 正在处理依赖关系 mysql-community-libs(x86-64) >= 8.0.11,它被软件包 mysql-community-client-8.0.26-1.el7.x86_64 需要
—> 软件包 mysql-community-common.x86_64.0.8.0.26-1.el7 将被 安装
–> 正在检查事务
—> 软件包 mariadb-libs.x86_64.1.5.5.64-1.el7 将被 取代
–> 正在处理依赖关系 libmysqlclient.so.18()(64bit),它被软件包 2:postfix-2.10.1-7.el7.x86_64 需要
–> 正在处理依赖关系 libmysqlclient.so.18(libmysqlclient_18)(64bit),它被软件包 2:postfix-2.10.1-7.el7.x86_64 需要
—> 软件包 mysql-community-client-plugins.x86_64.0.8.0.26-1.el7 将被 安装
—> 软件包 mysql-community-libs.x86_64.0.8.0.26-1.el7 将被 舍弃
–> 正在检查事务
—> 软件包 mysql-community-libs-compat.x86_64.0.8.0.26-1.el7 将被 舍弃
—> 软件包 postfix.x86_64.2.2.10.1-7.el7 将被 升级
—> 软件包 postfix.x86_64.2.2.10.1-9.el7 将被 更新
–> 解决依赖关系完成依赖关系解决
====================================================================================================================== Package 架构 版本
源 大小
====================================================================================================================== 正在安装: mysql-community-libs x86_64
8.0.26-1.el7 mysql80-community 4.0 M
替换 mariadb-libs.x86_64 1:5.5.64-1.el7 mysql-community-libs-compat x86_64 8.0.26-1.el7
mysql80-community 1.2 M
替换 mariadb-libs.x86_64 1:5.5.64-1.el7 mysql-community-server x86_64 8.0.26-1.el7 mysql80-community
434 M 为依赖而安装: mysql-community-client x86_64
8.0.26-1.el7 mysql80-community 46 M mysql-community-client-plugins x86_64 8.0.26-1.el7
mysql80-community 4.5 M mysql-community-common
x86_64 8.0.26-1.el7 mysql80-community
620 k 为依赖而更新: postfix x86_64
2:2.10.1-9.el7 base 2.4 M事务概要
====================================================================================================================== 安装 3 软件包 (+3 依赖软件包) 升级 ( 1 依赖软件包)总下载量:492 M Is this ok [y/d/N]: y Downloading packages: No Presto
metadata available for base
警告:/var/cache/yum/x86_64/7/mysql80-community/packages/mysql-community-client-plugins-8.0.26-1.el7.x86_64.rpm:
头V3 DSA/SHA256 Signature, 密钥 ID 5072e1f5: NOKEY
mysql-community-client-plugins-8.0.26-1.el7.x86_64.rpm 的公钥尚未安装 (1/7):
mysql-community-client-plugins-8.0.26-1.el7.x86_64.rpm
| 4.5 MB 00:00:05 (2/7):
mysql-community-common-8.0.26-1.el7.x86_64.rpm
| 620 kB 00:00:00 (3/7):
mysql-community-libs-8.0.26-1.el7.x86_64.rpm
| 4.0 MB 00:00:04 (4/7):
mysql-community-libs-compat-8.0.26-1.el7.x86_64.rpm
| 1.2 MB 00:00:01 (5/7): postfix-2.10.1-9.el7.x86_64.rpm
| 2.4 MB 00:00:06 (6/7):
mysql-community-client-8.0.26-1.el7.x86_64.rpm
| 46 MB 00:00:42 (7/7):
mysql-community-server-8.0.26-1.el7.x86_64.rpm
| 434 MB 00:05:07
---------------------------------------------------------------------------------------------------------------------- 总计
1.5 MB/s | 492 MB 00:05:19 从 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql 检索密钥 导入 GPG key 0x5072E1F5:
用户ID : “MySQL Release Engineering mysql-build@oss.oracle.com”
指纹 : a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5 软件包
: mysql80-community-release-el7-3.noarch (installed) 来自 :
/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql 是否继续?[y/N]:y Running transaction
check Running transaction test Transaction test succeeded Running
transaction 警告:RPM 数据库已被非 yum 程序修改。 正在安装 :
mysql-community-client-plugins-8.0.26-1.el7.x86_64
1/9 正在安装 : mysql-community-common-8.0.26-1.el7.x86_64
2/9 正在安装 : mysql-community-libs-8.0.26-1.el7.x86_64
3/9 正在安装 : mysql-community-libs-compat-8.0.26-1.el7.x86_64
4/9 正在安装 : mysql-community-client-8.0.26-1.el7.x86_64
5/9 正在安装 : mysql-community-server-8.0.26-1.el7.x86_64
6/9 正在更新 : 2:postfix-2.10.1-9.el7.x86_64
7/9 清理 : 2:postfix-2.10.1-7.el7.x86_64
8/9 正在删除 : 1:mariadb-libs-5.5.64-1.el7.x86_64
9/9 验证中 : 2:postfix-2.10.1-9.el7.x86_64
1/9 验证中 : mysql-community-libs-compat-8.0.26-1.el7.x86_64
2/9 验证中 : mysql-community-libs-8.0.26-1.el7.x86_64
3/9 验证中 : mysql-community-common-8.0.26-1.el7.x86_64
4/9 验证中 : mysql-community-server-8.0.26-1.el7.x86_64
5/9 验证中 : mysql-community-client-plugins-8.0.26-1.el7.x86_64
6/9 验证中 : mysql-community-client-8.0.26-1.el7.x86_64
7/9 验证中 : 1:mariadb-libs-5.5.64-1.el7.x86_64
8/9 验证中 : 2:postfix-2.10.1-7.el7.x86_64
9/9已安装: mysql-community-libs.x86_64 0:8.0.26-1.el7
mysql-community-libs-compat.x86_64 0:8.0.26-1.el7
mysql-community-server.x86_64 0:8.0.26-1.el7作为依赖被安装: mysql-community-client.x86_64 0:8.0.26-1.el7
mysql-community-client-plugins.x86_64 0:8.0.26-1.el7
mysql-community-common.x86_64 0:8.0.26-1.el7作为依赖被升级: postfix.x86_64 2:2.10.1-9.el7
替代: mariadb-libs.x86_64 1:5.5.64-1.el7
完毕!
启动MySQL.
[root@db ~]# systemctl start mysqld
#查看MySQL启动状态
[root@db ~]# systemctl status mysqld
● mysqld.service - MySQL Server Loaded: loaded
(/usr/lib/systemd/system/mysqld.service; enabled; vendor preset:
disabled) Active: active (running) since 五 2021-08-13 16:02:40 CST;
11s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html Process: 30361 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited,
status=0/SUCCESS) Main PID: 30449 (mysqld) Status: “Server is
operational”
Tasks: 38 CGroup: /system.slice/mysqld.service
└─30449 /usr/sbin/mysqld8月 13 16:02:28 db systemd[1]: Starting MySQL Server… 8月 13 16:02:40
db systemd[1]: Started MySQL Server.
查看临时密码
[root@db ~]# grep "A temporary password" /var/log/mysqld.log
“RGcLF%lu”就是临时密码
2021-08-13T08:02:36.442736Z 6 [Note] [MY-010454] [Server] A temporary
password is generated for root@localhost: RGcLF%lu:3mw
进入mysql并输入密码
[root@db ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL
connection id is 8 Server version: 8.0.26Copyright © 2000, 2021, Oracle and/or its affiliates.
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>
进入mysql
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
修改root密码
mysql> SET PASSWORD = '123456';
Query OK, 0 rows affected (0.10 sec)
创建远程登录链接
mysql> create user 'root'@'%' identified with mysql_native_password by 'root123456';
Query OK, 0 rows affected (0.00 sec)
mysql> grant all privileges on *.* to 'root'@'%' with grant option;
Query OK, 0 rows affected (0.01 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
退出MySQL
mysql> exit
关闭防火墙
[root@db ~]# systemctl stop firewalld