Table of contents
1. Go to the MySQL official website to download the Bundle tar package
2. Unzip the tar package and get the following files
3. Uninstall MariaDB that comes with the system
4. Install MySQL8 in the following order
6. Modify the default password to enable remote connection
1. Go to the MySQL official website to download the Bundle tar package
2. Unzip the tar package and get the following files
-rw-r--r--. 1 7155 31415 47810444 4月 26 15:36 mysql-community-client-8.0.25-1.el7.x86_64.rpm
-rw-r--r--. 1 7155 31415 193616 4月 26 15:36 mysql-community-client-plugins-8.0.25-1.el7.x86_64.rpm
-rw-r--r--. 1 7155 31415 628904 4月 26 15:36 mysql-community-common-8.0.25-1.el7.x86_64.rpm
-rw-r--r--. 1 7155 31415 6800820 4月 26 15:36 mysql-community-devel-8.0.25-1.el7.x86_64.rpm
-rw-r--r--. 1 7155 31415 23586756 4月 26 15:37 mysql-community-embedded-compat-8.0.25-1.el7.x86_64.rpm
-rw-r--r--. 1 7155 31415 4240320 4月 26 15:37 mysql-community-libs-8.0.25-1.el7.x86_64.rpm
-rw-r--r--. 1 7155 31415 1262876 4月 26 15:37 mysql-community-libs-compat-8.0.25-1.el7.x86_64.rpm
-rw-r--r--. 1 7155 31415 448614076 4月 26 15:38 mysql-community-server-8.0.25-1.el7.x86_64.rpm
-rw-r--r--. 1 7155 31415 260841936 4月 26 15:40 mysql-community-test-8.0.25-1.el7.x86_64.rpm
3. Uninstall MariaDB that comes with the system
rpm -qa | grep mariadb
rpm -e --nodeps mariadb-libs-5.5.44-2.el7.centos.x86_64
4. Install MySQL8 in the following order
1. rpm -ivh mysql-community-common-8.0.25-1.el7.x86_64.rpm
2. rpm -ivh mysql-community-client-plugins-8.0.25-1.el7.x86_64.rpm
3. rpm -ivh mysql-community-libs-8.0.25-1.el7.x86_64.rpm
4. rpm -ivh mysql-community-client-8.0.25-1.el7.x86_64.rpm
5. rpm -ivh mysql-community-server-8.0.25-1.el7.x86_64.rpm
6. rpm -ivh mysql-community-devel-8.0.25-1.el7.x86_64.rpm
4.1 When installing mysql-community-server-8.0.25-1.el7.x86_64.rpm, you need to rely on net-tools. If there is no net-tools, the installation will fail. At this time, install net-tools first, and then install mysql-community-server-8.0.25-1.el7.x86_64.rpm
# 安装 mysql-community-server-8.0.25-1.el7.x86_64.rpm 依赖报错
[root@sangni mysql-installation]# rpm -ivh mysql-community-server-8.0.25-1.el7.x86_64.rpm
警告:mysql-community-server-8.0.25-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
错误:依赖检测失败:
net-tools 被 mysql-community-server-8.0.25-1.el7.x86_64 需要
# 安装 net-tools
[root@sangni mysql-installation]# yum install net-tools
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.njupt.edu.cn
* extras: mirrors.njupt.edu.cn
* updates: mirrors.njupt.edu.cn
正在解决依赖关系
--> 正在检查事务
---> 软件包 net-tools.x86_64.0.2.0-0.25.20131004git.el7 将被 安装
--> 解决依赖关系完成
依赖关系解决
==================================================================================================================================
Package 架构 版本 源 大小
==================================================================================================================================
正在安装:
net-tools x86_64 2.0-0.25.20131004git.el7 base 306 k
事务概要
==================================================================================================================================
安装 1 软件包
总下载量:306 k
安装大小:917 k
Is this ok [y/d/N]: y
Downloading packages:
net-tools-2.0-0.25.20131004git.el7.x86_64.rpm | 306 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
警告:RPM 数据库已被非 yum 程序修改。
** 发现 2 个已存在的 RPM 数据库问题, 'yum check' 输出如下:
2:postfix-2.10.1-9.el7.x86_64 有缺少的需求 libmysqlclient.so.18()(64bit)
2:postfix-2.10.1-9.el7.x86_64 有缺少的需求 libmysqlclient.so.18(libmysqlclient_18)(64bit)
正在安装 : net-tools-2.0-0.25.20131004git.el7.x86_64 1/1
验证中 : net-tools-2.0-0.25.20131004git.el7.x86_64 1/1
已安装:
net-tools.x86_64 0:2.0-0.25.20131004git.el7
完毕!
# net-tools 安装完成后再次安装 mysql-community-server-8.0.25-1.el7.x86_64.rpm
[root@sangni mysql-installation]# rpm -ivh mysql-community-server-8.0.25-1.el7.x86_64.rpm
警告:mysql-community-server-8.0.25-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:mysql-community-server-8.0.25-1.e################################# [100%]
4.2 When installing mysql-community-devel-8.0.25-1.el7.x86_64.rpm, you need to rely on pkgconfig (openssl). If an error is reported, you can also install openssl-devel first.
# 安装 mysql-community-devel-8.0.25-1.el7.x86_64.rpm 依赖报错
[root@sangni mysql-installation]# rpm -ivh mysql-community-devel-8.0.25-1.el7.x86_64.rpm
警告:mysql-community-devel-8.0.25-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
错误:依赖检测失败:
pkgconfig(openssl) 被 mysql-community-devel-8.0.25-1.el7.x86_64 需要
# 安装 openssl-devel
[root@sangni mysql-installation]# yum install openssl-devel
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.njupt.edu.cn
* extras: mirrors.njupt.edu.cn
* updates: mirrors.njupt.edu.cn
正在解决依赖关系
--> 正在检查事务
---> 软件包 openssl-devel.x86_64.1.1.0.2k-21.el7_9 将被 安装
--> 正在处理依赖关系 zlib-devel(x86-64),它被软件包 1:openssl-devel-1.0.2k-21.el7_9.x86_64 需要
--> 正在处理依赖关系 krb5-devel(x86-64),它被软件包 1:openssl-devel-1.0.2k-21.el7_9.x86_64 需要
--> 正在检查事务
---> 软件包 krb5-devel.x86_64.0.1.15.1-50.el7 将被 安装
--> 正在处理依赖关系 libkadm5(x86-64) = 1.15.1-50.el7,它被软件包 krb5-devel-1.15.1-50.el7.x86_64 需要
--> 正在处理依赖关系 libverto-devel,它被软件包 krb5-devel-1.15.1-50.el7.x86_64 需要
--> 正在处理依赖关系 libselinux-devel,它被软件包 krb5-devel-1.15.1-50.el7.x86_64 需要
--> 正在处理依赖关系 libcom_err-devel,它被软件包 krb5-devel-1.15.1-50.el7.x86_64 需要
--> 正在处理依赖关系 keyutils-libs-devel,它被软件包 krb5-devel-1.15.1-50.el7.x86_64 需要
---> 软件包 zlib-devel.x86_64.0.1.2.7-19.el7_9 将被 安装
--> 正在检查事务
---> 软件包 keyutils-libs-devel.x86_64.0.1.5.8-3.el7 将被 安装
---> 软件包 libcom_err-devel.x86_64.0.1.42.9-19.el7 将被 安装
---> 软件包 libkadm5.x86_64.0.1.15.1-50.el7 将被 安装
---> 软件包 libselinux-devel.x86_64.0.2.5-15.el7 将被 安装
--> 正在处理依赖关系 libsepol-devel(x86-64) >= 2.5-10,它被软件包 libselinux-devel-2.5-15.el7.x86_64 需要
--> 正在处理依赖关系 pkgconfig(libsepol),它被软件包 libselinux-devel-2.5-15.el7.x86_64 需要
--> 正在处理依赖关系 pkgconfig(libpcre),它被软件包 libselinux-devel-2.5-15.el7.x86_64 需要
---> 软件包 libverto-devel.x86_64.0.0.2.5-4.el7 将被 安装
--> 正在检查事务
---> 软件包 libsepol-devel.x86_64.0.2.5-10.el7 将被 安装
---> 软件包 pcre-devel.x86_64.0.8.32-17.el7 将被 安装
--> 解决依赖关系完成
依赖关系解决
==================================================================================================================================
Package 架构 版本 源 大小
==================================================================================================================================
正在安装:
openssl-devel x86_64 1:1.0.2k-21.el7_9 updates 1.5 M
为依赖而安装:
keyutils-libs-devel x86_64 1.5.8-3.el7 base 37 k
krb5-devel x86_64 1.15.1-50.el7 base 273 k
libcom_err-devel x86_64 1.42.9-19.el7 base 32 k
libkadm5 x86_64 1.15.1-50.el7 base 179 k
libselinux-devel x86_64 2.5-15.el7 base 187 k
libsepol-devel x86_64 2.5-10.el7 base 77 k
libverto-devel x86_64 0.2.5-4.el7 base 12 k
pcre-devel x86_64 8.32-17.el7 base 480 k
zlib-devel x86_64 1.2.7-19.el7_9 updates 50 k
事务概要
==================================================================================================================================
安装 1 软件包 (+9 依赖软件包)
总下载量:2.8 M
安装大小:6.0 M
Is this ok [y/d/N]: Is this ok [y/d/N]: y
Downloading packages:
(1/10): libcom_err-devel-1.42.9-19.el7.x86_64.rpm | 32 kB 00:00:00
(2/10): keyutils-libs-devel-1.5.8-3.el7.x86_64.rpm | 37 kB 00:00:00
(3/10): krb5-devel-1.15.1-50.el7.x86_64.rpm | 273 kB 00:00:00
(4/10): libkadm5-1.15.1-50.el7.x86_64.rpm | 179 kB 00:00:00
(5/10): libselinux-devel-2.5-15.el7.x86_64.rpm | 187 kB 00:00:00
(6/10): libverto-devel-0.2.5-4.el7.x86_64.rpm | 12 kB 00:00:00
(7/10): libsepol-devel-2.5-10.el7.x86_64.rpm | 77 kB 00:00:00
(8/10): zlib-devel-1.2.7-19.el7_9.x86_64.rpm | 50 kB 00:00:00
(9/10): openssl-devel-1.0.2k-21.el7_9.x86_64.rpm | 1.5 MB 00:00:00
(10/10): pcre-devel-8.32-17.el7.x86_64.rpm | 480 kB 00:00:00
----------------------------------------------------------------------------------------------------------------------------------
总计 2.0 MB/s | 2.8 MB 00:00:01
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : libkadm5-1.15.1-50.el7.x86_64 1/10
正在安装 : libsepol-devel-2.5-10.el7.x86_64 2/10
正在安装 : libcom_err-devel-1.42.9-19.el7.x86_64 3/10
正在安装 : zlib-devel-1.2.7-19.el7_9.x86_64 4/10
正在安装 : pcre-devel-8.32-17.el7.x86_64 5/10
正在安装 : libselinux-devel-2.5-15.el7.x86_64 6/10
正在安装 : keyutils-libs-devel-1.5.8-3.el7.x86_64 7/10
正在安装 : libverto-devel-0.2.5-4.el7.x86_64 8/10
正在安装 : krb5-devel-1.15.1-50.el7.x86_64 9/10
正在安装 : 1:openssl-devel-1.0.2k-21.el7_9.x86_64 10/10
验证中 : libselinux-devel-2.5-15.el7.x86_64 1/10
验证中 : 1:openssl-devel-1.0.2k-21.el7_9.x86_64 2/10
验证中 : libverto-devel-0.2.5-4.el7.x86_64 3/10
验证中 : krb5-devel-1.15.1-50.el7.x86_64 4/10
验证中 : keyutils-libs-devel-1.5.8-3.el7.x86_64 5/10
验证中 : pcre-devel-8.32-17.el7.x86_64 6/10
验证中 : zlib-devel-1.2.7-19.el7_9.x86_64 7/10
验证中 : libcom_err-devel-1.42.9-19.el7.x86_64 8/10
验证中 : libsepol-devel-2.5-10.el7.x86_64 9/10
验证中 : libkadm5-1.15.1-50.el7.x86_64 10/10
已安装:
openssl-devel.x86_64 1:1.0.2k-21.el7_9
作为依赖被安装:
keyutils-libs-devel.x86_64 0:1.5.8-3.el7 krb5-devel.x86_64 0:1.15.1-50.el7 libcom_err-devel.x86_64 0:1.42.9-19.el7
libkadm5.x86_64 0:1.15.1-50.el7 libselinux-devel.x86_64 0:2.5-15.el7 libsepol-devel.x86_64 0:2.5-10.el7
libverto-devel.x86_64 0:0.2.5-4.el7 pcre-devel.x86_64 0:8.32-17.el7 zlib-devel.x86_64 0:1.2.7-19.el7_9
完毕!
# 再次安装 mysql-community-devel-8.0.25-1.el7.x86_64.rpm
[root@sangni mysql-installation]# rpm -ivh mysql-community-devel-8.0.25-1.el7.x86_64.rpm
警告:mysql-community-devel-8.0.25-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:mysql-community-devel-8.0.25-1.el################################# [100%]
5. Start the MySQL service
# 启动 MySQL 服务
[root@sangni mysql-installation]# service mysqld start
Redirecting to /bin/systemctl start mysqld.service
# 查看启动状态
[root@sangni mysql-installation]# service status mysqld
The service command supports only basic LSB actions (start, stop, restart, try-restart, reload, force-reload, status). For other actions, please try to use systemctl.
[root@sangni mysql-installation]# service mysqld status
Redirecting to /bin/systemctl status mysqld.service
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since 一 2021-06-14 13:50:41 CST; 29s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 7989 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 8070 (mysqld)
Status: "Server is operational"
CGroup: /system.slice/mysqld.service
└─8070 /usr/sbin/mysqld
6月 14 13:50:31 sangni systemd[1]: Starting MySQL Server...
6月 14 13:50:41 sangni systemd[1]: Started MySQL Server.
6. Modify the default password to enable remote connection
# 查看默认密码
[root@sangni ~]# grep 'temporary password' /var/log/mysqld.log
2021-06-14T05:50:35.796216Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: wfz2/(r6oiwM
# 使用默认密码登陆 MySQL
[root@sangni log]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.25
Copyright (c) 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> select version();
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
# 修改 root 用户密码
mysql> alter user 'root'@'localhost' identified by 'xxxx';
Query OK, 0 rows affected (0.01 sec)
# 查看 MySQL 版本
mysql> select version();
+-----------+
| version() |
+-----------+
| 8.0.25 |
+-----------+
1 row in set (0.00 sec)
# 使用 MySQL Schema/Database
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 用户的 host 列值,开启远程连接
mysql> update user set host='%' where user ='root';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
# 刷新缓存
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)
# 给 root 用户授予所有权限
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'WITH GRANT OPTION;
Query OK, 0 rows affected (0.01 sec)
【over】