前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >CentOS 8 安装MySQL(各版本完美解决方案)

CentOS 8 安装MySQL(各版本完美解决方案)

作者头像
猫头虎
发布2024-04-07 16:08:40
9120
发布2024-04-07 16:08:40
举报
文章被收录于专栏:猫头虎博客专区

首先,换yum源

  1. 下载对应版本的repo文件

wget -O CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo

  1. 清除旧的yum缓存并生成新的yum缓存

代码语言:javascript
复制
# yum clean all
# yum makecache
  1. 更新
代码语言:javascript
复制
# yum update -y

下面根据需求,安装对应版本的MySQL

安装mysql5.6

wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm

rpm -ivh mysql-community-release-el7-5.noarch.rpm

yum install mysql-server -y

service mysqld start

service mysqld status

systemctl enable mysqld.service

grep “password” /var/log/mysqld.log找初始密码,如果报找不到文件那就试试grep “password” /var/log/mysql/mysqld.log

mysqladmin -uroot -p password NewPassword回车输入初始密码来重置密码

安装mysql5.7

wget http://repo.mysql.com/mysql57-community-release-el7-11.noarch.rpm

rpm -ivh mysql57-community-release-el7-11.noarch.rpm

yum install mysql-server -y

service mysqld start

service mysqld status

systemctl enable mysqld.service

grep “password” /var/log/mysqld.log找初始密码,如果报找不到文件那就试试grep “password” /var/log/mysql/mysqld.log

mysqladmin -uroot -p password NewPassword回车输入初始密码来重置密码

安装mysql8.0

wget http://repo.mysql.com/mysql80-community-release-el7-3.noarch.rpm

rpm -ivh mysql80-community-release-el7-3.noarch.rpm

yum install mysql-server -y

service mysqld start

service mysqld status

systemctl enable mysqld.service

配置8.0版本 修改密码,默认也是没有密码的直接回车输入新密码

代码语言:javascript
复制
 [root@localhost ~]# mysqladmin -uroot -p password 
Enter password: 
New password: 
Confirm new password: 
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.

方法一:  Mysql默认不允许远程登录,所以需要开启远程访问权限

可以先查看user表

select user,authentication_string,host from user;

默认都是localhost

update user set host = ‘%’ where user = ‘root’;

代码语言:javascript
复制
flush privileges;

如果没有开放连接权限,使用navicat等客户端连接数据库时会报如下错误:

3、还原密码验证插件,将MySQL8的密码认证插件由caching_sha2_password更换成mysql_native_password:

代码语言:javascript
复制
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'passowrd';

如果没有更换插件,连接时会报如下错误:

注意事项:

如果报以下错误,可根据提示删除掉对应的冲突包

代码语言:javascript
复制
[root@localhost ~]# rpm -ivh mysql57-community-release-el7-11.noarch.rpm
警告:mysql57-community-release-el7-11.noarch.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
错误:依赖检测失败:
        mysql-community-release 与 mysql57-community-release-el7-11.noarch 冲突
代码语言:javascript
复制
    命令如下格式:
    rpm -e --nodeps 后面加上冲突的文件名,如下:
     rpm -e --nodeps  mysql-community-release

之后在执行安装程序即可完整安装

另外,针对学习阶段,

MySQL5.7不能修改简单密码的问题

,我这里做了总结,请参考: MySQL5.7修改密码问题解决方案

最后献上我今天安装MySQL的过程指令:

代码语言:javascript
复制
Activate the web console with: systemctl enable --now cockpit.socket

Last login: Mon May 10 13:44:32 2021
[root@localhost ~]# systemctl start mysqld
Failed to start mysqld.service: Unit mysqld.service not found.
[root@localhost ~]# wget http://repo.mysql.com/mysql80-community-release-el7-3.noarch.rpm
--2021-05-10 13:46:11--  http://repo.mysql.com/mysql80-community-release-el7-3.noarch.rpm
正在解析主机 repo.mysql.com (repo.mysql.com)... 23.200.153.25
正在连接 repo.mysql.com (repo.mysql.com)|23.200.153.25|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:26024 (25K) [application/x-redhat-package-manager]
正在保存至: “mysql80-community-release-el7-3.noarch.rpm”

mysql80-community-release-el7 100%[================================================>]  25.41K   159KB/s  用时 0.2s    

2021-05-10 13:46:13 (159 KB/s) - 已保存 “mysql80-community-release-el7-3.noarch.rpm” [26024/26024])

[root@localhost ~]# rpm -ivh mysql80-community-release-el7-3.noarch.rpm
警告:mysql80-community-release-el7-3.noarch.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
Verifying...                          ################################# [100%]
准备中...                          ################################# [100%]
正在升级/安装...
   1:mysql80-community-release-el7-3  ################################# [100%]
[root@localhost ~]# yum install mysql-server -y
MySQL 8.0 Community Server                                                             273 kB/s | 1.7 MB     00:06    
MySQL Connectors Community                                                              48 kB/s | 107 kB     00:02    
MySQL Tools Community                                                                  178 kB/s | 630 kB     00:03    
依赖关系解决。
=======================================================================================================================
 软件包                             架构         版本                                            仓库             大小
=======================================================================================================================
安装:
 mysql-server                       x86_64       8.0.21-1.module_el8.2.0+493+63b41e36            appstream        22 M
安装依赖关系:
 checkpolicy                        x86_64       2.9-1.el8                                       baseos          348 k
 mariadb-connector-c-config         noarch       3.1.11-2.el8_3                                  appstream        15 k
 mecab                              x86_64       0.996-1.module_el8.2.0+493+63b41e36.9           appstream       393 k
 mysql                              x86_64       8.0.21-1.module_el8.2.0+493+63b41e36            appstream        12 M
 mysql-common                       x86_64       8.0.21-1.module_el8.2.0+493+63b41e36            appstream       148 k
 mysql-errmsg                       x86_64       8.0.21-1.module_el8.2.0+493+63b41e36            appstream       581 k
 perl-Carp                          noarch       1.42-396.el8                                    baseos           30 k
 perl-Data-Dumper                   x86_64       2.167-399.el8                                   baseos           58 k
 perl-Digest                        noarch       1.17-395.el8                                    appstream        27 k
 perl-Digest-MD5                    x86_64       2.55-396.el8                                    appstream        37 k
 perl-Encode                        x86_64       4:2.97-3.el8                                    baseos          1.5 M
 perl-Errno                         x86_64       1.28-416.el8                                    baseos           76 k
 perl-Exporter                      noarch       5.72-396.el8                                    baseos           34 k
 perl-File-Path                     noarch       2.15-2.el8                                      baseos           38 k
 perl-File-Temp                     noarch       0.230.600-1.el8                                 baseos           63 k
 perl-Getopt-Long                   noarch       1:2.50-4.el8                                    baseos           63 k
 perl-HTTP-Tiny                     noarch       0.074-1.el8                                     baseos           58 k
 perl-IO                            x86_64       1.38-416.el8                                    baseos          141 k
 perl-MIME-Base64                   x86_64       3.15-396.el8                                    baseos           31 k
 perl-Net-SSLeay                    x86_64       1.88-1.module_el8.3.0+410+ff426aa3              appstream       379 k
 perl-PathTools                     x86_64       3.74-1.el8                                      baseos           90 k
 perl-Pod-Escapes                   noarch       1:1.07-395.el8                                  baseos           20 k
 perl-Pod-Perldoc                   noarch       3.28-396.el8                                    baseos           86 k
 perl-Pod-Simple                    noarch       1:3.35-395.el8                                  baseos          213 k
 perl-Pod-Usage                     noarch       4:1.69-395.el8                                  baseos           34 k
 perl-Scalar-List-Utils             x86_64       3:1.49-2.el8                                    baseos           68 k
 perl-Socket                        x86_64       4:2.027-3.el8                                   baseos           59 k
 perl-Storable                      x86_64       1:3.11-3.el8                                    baseos           98 k
 perl-Term-ANSIColor                noarch       4.06-396.el8                                    baseos           46 k
 perl-Term-Cap                      noarch       1.17-395.el8                                    baseos           23 k
 perl-Text-ParseWords               noarch       3.30-395.el8                                    baseos           18 k
 perl-Text-Tabs+Wrap                noarch       2013.0523-395.el8                               baseos           24 k
 perl-Time-Local                    noarch       1:1.280-1.el8                                   baseos           34 k
 perl-URI                           noarch       1.73-3.el8                                      appstream       116 k
 perl-Unicode-Normalize             x86_64       1.25-396.el8                                    baseos           82 k
 perl-constant                      noarch       1.33-396.el8                                    baseos           25 k
 perl-interpreter                   x86_64       4:5.26.3-416.el8                                baseos          6.3 M
 perl-libnet                        noarch       3.11-3.el8                                      appstream       121 k
 perl-libs                          x86_64       4:5.26.3-416.el8                                baseos          1.6 M
 perl-macros                        x86_64       4:5.26.3-416.el8                                baseos           72 k
 perl-parent                        noarch       1:0.237-1.el8                                   baseos           20 k
 perl-podlators                     noarch       4.11-1.el8                                      baseos          118 k
 perl-threads                       x86_64       1:2.21-2.el8                                    baseos           61 k
 perl-threads-shared                x86_64       1.58-2.el8                                      baseos           48 k
 policycoreutils-python-utils       noarch       2.9-9.el8                                       baseos          251 k
 protobuf-lite                      x86_64       3.5.0-13.el8                                    appstream       149 k
 python3-audit                      x86_64       3.0-0.17.20191104git1c2f876.el8                 baseos           86 k
 python3-libsemanage                x86_64       2.9-3.el8                                       baseos          127 k
 python3-policycoreutils            noarch       2.9-9.el8                                       baseos          2.2 M
 python3-setools                    x86_64       4.3.0-2.el8                                     baseos          626 k
安装弱的依赖:
 perl-IO-Socket-IP                  noarch       0.39-5.el8                                      appstream        47 k
 perl-IO-Socket-SSL                 noarch       2.066-4.module_el8.3.0+410+ff426aa3             appstream       298 k
 perl-Mozilla-CA                    noarch       20160104-7.module_el8.3.0+416+dee7bcef          appstream        15 k
启用模块流:
 mysql                                           8.0                                                                  
 perl                                            5.26                                                                 
 perl-IO-Socket-SSL                              2.066                                                                
 perl-libwww-perl                                6.34                                                                 

事务概要
=======================================================================================================================
安装  54 软件包

总下载:51 M
安装大小:228 M
下载软件包:
(1/54): mariadb-connector-c-config-3.1.11-2.el8_3.noarch.rpm                            90 kB/s |  15 kB     00:00    
(2/54): mecab-0.996-1.module_el8.2.0+493+63b41e36.9.x86_64.rpm                         773 kB/s | 393 kB     00:00    
(3/54): mysql-errmsg-8.0.21-1.module_el8.2.0+493+63b41e36.x86_64.rpm                   1.3 MB/s | 581 kB     00:00    
(4/54): mysql-common-8.0.21-1.module_el8.2.0+493+63b41e36.x86_64.rpm                   150 kB/s | 148 kB     00:00    
(5/54): perl-Digest-1.17-395.el8.noarch.rpm                                             88 kB/s |  27 kB     00:00    
(6/54): perl-Digest-MD5-2.55-396.el8.x86_64.rpm                                        565 kB/s |  37 kB     00:00    
(7/54): perl-IO-Socket-IP-0.39-5.el8.noarch.rpm                                        111 kB/s |  47 kB     00:00    
(8/54): mysql-8.0.21-1.module_el8.2.0+493+63b41e36.x86_64.rpm                          961 kB/s |  12 MB     00:12    
(9/54): perl-Mozilla-CA-20160104-7.module_el8.3.0+416+dee7bcef.noarch.rpm              378 kB/s |  15 kB     00:00    
(10/54): perl-Net-SSLeay-1.88-1.module_el8.3.0+410+ff426aa3.x86_64.rpm                 446 kB/s | 379 kB     00:00    
(11/54): perl-URI-1.73-3.el8.noarch.rpm                                                868 kB/s | 116 kB     00:00    
(12/54): perl-libnet-3.11-3.el8.noarch.rpm                                             306 kB/s | 121 kB     00:00    
(13/54): protobuf-lite-3.5.0-13.el8.x86_64.rpm                                         285 kB/s | 149 kB     00:00    
(14/54): perl-IO-Socket-SSL-2.066-4.module_el8.3.0+410+ff426aa3.noarch.rpm              21 kB/s | 298 kB     00:14    
(15/54): perl-Carp-1.42-396.el8.noarch.rpm                                              56 kB/s |  30 kB     00:00    
(16/54): perl-Data-Dumper-2.167-399.el8.x86_64.rpm                                     111 kB/s |  58 kB     00:00    
(17/54): checkpolicy-2.9-1.el8.x86_64.rpm                                               91 kB/s | 348 kB     00:03    
(18/54): perl-Errno-1.28-416.el8.x86_64.rpm                                             26 kB/s |  76 kB     00:02    
(19/54): perl-Exporter-5.72-396.el8.noarch.rpm                                          50 kB/s |  34 kB     00:00    
(20/54): perl-File-Path-2.15-2.el8.noarch.rpm                                           18 kB/s |  38 kB     00:02    
(21/54): perl-File-Temp-0.230.600-1.el8.noarch.rpm                                      51 kB/s |  63 kB     00:01    
(22/54): perl-Getopt-Long-2.50-4.el8.noarch.rpm                                         24 kB/s |  63 kB     00:02    
(23/54): perl-HTTP-Tiny-0.074-1.el8.noarch.rpm                                          54 kB/s |  58 kB     00:01    
(24/54): perl-IO-1.38-416.el8.x86_64.rpm                                                40 kB/s | 141 kB     00:03    
(25/54): perl-MIME-Base64-3.15-396.el8.x86_64.rpm                                       53 kB/s |  31 kB     00:00    
(26/54): perl-PathTools-3.74-1.el8.x86_64.rpm                                           67 kB/s |  90 kB     00:01    
(27/54): perl-Pod-Escapes-1.07-395.el8.noarch.rpm                                       18 kB/s |  20 kB     00:01    
(28/54): mysql-server-8.0.21-1.module_el8.2.0+493+63b41e36.x86_64.rpm                  653 kB/s |  22 MB     00:34    
(29/54): perl-Encode-2.97-3.el8.x86_64.rpm                                              80 kB/s | 1.5 MB     00:18    
(30/54): perl-Pod-Usage-1.69-395.el8.noarch.rpm                                         74 kB/s |  34 kB     00:00    
(31/54): perl-Pod-Simple-3.35-395.el8.noarch.rpm                                       146 kB/s | 213 kB     00:01    
(32/54): perl-Socket-2.027-3.el8.x86_64.rpm                                             27 kB/s |  59 kB     00:02    
(33/54): perl-Pod-Perldoc-3.28-396.el8.noarch.rpm                                       22 kB/s |  86 kB     00:03    
(34/54): perl-Term-ANSIColor-4.06-396.el8.noarch.rpm                                    49 kB/s |  46 kB     00:00    
(35/54): perl-Storable-3.11-3.el8.x86_64.rpm                                            79 kB/s |  98 kB     00:01    
(36/54): perl-Term-Cap-1.17-395.el8.noarch.rpm                                          54 kB/s |  23 kB     00:00    
(37/54): perl-Text-ParseWords-3.30-395.el8.noarch.rpm                                   73 kB/s |  18 kB     00:00    
(38/54): perl-Scalar-List-Utils-1.49-2.el8.x86_64.rpm                                   15 kB/s |  68 kB     00:04    
(39/54): perl-Text-Tabs+Wrap-2013.0523-395.el8.noarch.rpm                               61 kB/s |  24 kB     00:00    
(40/54): perl-Time-Local-1.280-1.el8.noarch.rpm                                         86 kB/s |  34 kB     00:00    
(41/54): perl-constant-1.33-396.el8.noarch.rpm                                          28 kB/s |  25 kB     00:00    
(42/54): perl-Unicode-Normalize-1.25-396.el8.x86_64.rpm                                 63 kB/s |  82 kB     00:01    
(43/54): perl-macros-5.26.3-416.el8.x86_64.rpm                                          71 kB/s |  72 kB     00:01    
(44/54): perl-parent-0.237-1.el8.noarch.rpm                                             38 kB/s |  20 kB     00:00    
(45/54): perl-podlators-4.11-1.el8.noarch.rpm                                           37 kB/s | 118 kB     00:03    
(46/54): perl-threads-2.21-2.el8.x86_64.rpm                                             41 kB/s |  61 kB     00:01    
(47/54): perl-threads-shared-1.58-2.el8.x86_64.rpm                                      34 kB/s |  48 kB     00:01    
(48/54): policycoreutils-python-utils-2.9-9.el8.noarch.rpm                              86 kB/s | 251 kB     00:02    
(49/54): python3-audit-3.0-0.17.20191104git1c2f876.el8.x86_64.rpm                       84 kB/s |  86 kB     00:01    
(50/54): python3-libsemanage-2.9-3.el8.x86_64.rpm                                       71 kB/s | 127 kB     00:01    
(51/54): perl-libs-5.26.3-416.el8.x86_64.rpm                                            86 kB/s | 1.6 MB     00:18    
(52/54): python3-setools-4.3.0-2.el8.x86_64.rpm                                         72 kB/s | 626 kB     00:08    
(53/54): python3-policycoreutils-2.9-9.el8.noarch.rpm                                  121 kB/s | 2.2 MB     00:18    
(54/54): perl-interpreter-5.26.3-416.el8.x86_64.rpm                                    119 kB/s | 6.3 MB     00:54    
-----------------------------------------------------------------------------------------------------------------------
总计                                                                                   528 kB/s |  51 MB     01:39     
运行事务检查
事务检查成功。
运行事务测试
事务测试成功。
运行事务
  准备中  :                                                                                                        1/1 
  安装    : perl-Exporter-5.72-396.el8.noarch                                                                     1/54 
  安装    : perl-libs-4:5.26.3-416.el8.x86_64                                                                     2/54 
  安装    : perl-Carp-1.42-396.el8.noarch                                                                         3/54 
  安装    : perl-Scalar-List-Utils-3:1.49-2.el8.x86_64                                                            4/54 
  安装    : perl-parent-1:0.237-1.el8.noarch                                                                      5/54 
  安装    : perl-Text-ParseWords-3.30-395.el8.noarch                                                              6/54 
  安装    : mariadb-connector-c-config-3.1.11-2.el8_3.noarch                                                      7/54 
  安装    : mysql-common-8.0.21-1.module_el8.2.0+493+63b41e36.x86_64                                              8/54 
  安装    : mysql-8.0.21-1.module_el8.2.0+493+63b41e36.x86_64                                                     9/54 
  安装    : mysql-errmsg-8.0.21-1.module_el8.2.0+493+63b41e36.x86_64                                             10/54 
  安装    : perl-Term-ANSIColor-4.06-396.el8.noarch                                                              11/54 
  安装    : perl-macros-4:5.26.3-416.el8.x86_64                                                                  12/54 
  安装    : perl-Errno-1.28-416.el8.x86_64                                                                       13/54 
  安装    : perl-Socket-4:2.027-3.el8.x86_64                                                                     14/54 
  安装    : perl-Text-Tabs+Wrap-2013.0523-395.el8.noarch                                                         15/54 
  安装    : perl-Unicode-Normalize-1.25-396.el8.x86_64                                                           16/54 
  安装    : perl-File-Path-2.15-2.el8.noarch                                                                     17/54 
  安装    : perl-IO-1.38-416.el8.x86_64                                                                          18/54 
  安装    : perl-PathTools-3.74-1.el8.x86_64                                                                     19/54 
  安装    : perl-constant-1.33-396.el8.noarch                                                                    20/54 
  安装    : perl-threads-1:2.21-2.el8.x86_64                                                                     21/54 
  安装    : perl-threads-shared-1.58-2.el8.x86_64                                                                22/54 
  安装    : perl-interpreter-4:5.26.3-416.el8.x86_64                                                             23/54 
  安装    : perl-MIME-Base64-3.15-396.el8.x86_64                                                                 24/54 
  安装    : perl-IO-Socket-IP-0.39-5.el8.noarch                                                                  25/54 
  安装    : perl-Time-Local-1:1.280-1.el8.noarch                                                                 26/54 
  安装    : perl-Digest-1.17-395.el8.noarch                                                                      27/54 
  安装    : perl-Digest-MD5-2.55-396.el8.x86_64                                                                  28/54 
  安装    : perl-Net-SSLeay-1.88-1.module_el8.3.0+410+ff426aa3.x86_64                                            29/54 
  安装    : perl-Data-Dumper-2.167-399.el8.x86_64                                                                30/54 
  安装    : perl-File-Temp-0.230.600-1.el8.noarch                                                                31/54 
  安装    : perl-Pod-Escapes-1:1.07-395.el8.noarch                                                               32/54 
  安装    : perl-Storable-1:3.11-3.el8.x86_64                                                                    33/54 
  安装    : perl-Term-Cap-1.17-395.el8.noarch                                                                    34/54 
  安装    : perl-Mozilla-CA-20160104-7.module_el8.3.0+416+dee7bcef.noarch                                        35/54 
  安装    : perl-Encode-4:2.97-3.el8.x86_64                                                                      36/54 
  安装    : perl-Pod-Simple-1:3.35-395.el8.noarch                                                                37/54 
  安装    : perl-Getopt-Long-1:2.50-4.el8.noarch                                                                 38/54 
  安装    : perl-podlators-4.11-1.el8.noarch                                                                     39/54 
  安装    : perl-Pod-Usage-4:1.69-395.el8.noarch                                                                 40/54 
  安装    : perl-Pod-Perldoc-3.28-396.el8.noarch                                                                 41/54 
  安装    : perl-HTTP-Tiny-0.074-1.el8.noarch                                                                    42/54 
  安装    : perl-IO-Socket-SSL-2.066-4.module_el8.3.0+410+ff426aa3.noarch                                        43/54 
  安装    : perl-libnet-3.11-3.el8.noarch                                                                        44/54 
  安装    : perl-URI-1.73-3.el8.noarch                                                                           45/54 
  安装    : python3-setools-4.3.0-2.el8.x86_64                                                                   46/54 
  安装    : python3-libsemanage-2.9-3.el8.x86_64                                                                 47/54 
  安装    : python3-audit-3.0-0.17.20191104git1c2f876.el8.x86_64                                                 48/54 
  安装    : checkpolicy-2.9-1.el8.x86_64                                                                         49/54 
  安装    : python3-policycoreutils-2.9-9.el8.noarch                                                             50/54 
  安装    : policycoreutils-python-utils-2.9-9.el8.noarch                                                        51/54 
  安装    : protobuf-lite-3.5.0-13.el8.x86_64                                                                    52/54 
  安装    : mecab-0.996-1.module_el8.2.0+493+63b41e36.9.x86_64                                                   53/54 
  运行脚本: mecab-0.996-1.module_el8.2.0+493+63b41e36.9.x86_64                                                   53/54 
  运行脚本: mysql-server-8.0.21-1.module_el8.2.0+493+63b41e36.x86_64                                             54/54 
  安装    : mysql-server-8.0.21-1.module_el8.2.0+493+63b41e36.x86_64                                             54/54 
  运行脚本: mysql-server-8.0.21-1.module_el8.2.0+493+63b41e36.x86_64                                             54/54 
ValueError: /var/log/mysql(/.*)? 的文件上下文已定义

  验证    : mariadb-connector-c-config-3.1.11-2.el8_3.noarch                                                      1/54 
  验证    : mecab-0.996-1.module_el8.2.0+493+63b41e36.9.x86_64                                                    2/54 
  验证    : mysql-8.0.21-1.module_el8.2.0+493+63b41e36.x86_64                                                     3/54 
  验证    : mysql-common-8.0.21-1.module_el8.2.0+493+63b41e36.x86_64                                              4/54 
  验证    : mysql-errmsg-8.0.21-1.module_el8.2.0+493+63b41e36.x86_64                                              5/54 
  验证    : mysql-server-8.0.21-1.module_el8.2.0+493+63b41e36.x86_64                                              6/54 
  验证    : perl-Digest-1.17-395.el8.noarch                                                                       7/54 
  验证    : perl-Digest-MD5-2.55-396.el8.x86_64                                                                   8/54 
  验证    : perl-IO-Socket-IP-0.39-5.el8.noarch                                                                   9/54 
  验证    : perl-IO-Socket-SSL-2.066-4.module_el8.3.0+410+ff426aa3.noarch                                        10/54 
  验证    : perl-Mozilla-CA-20160104-7.module_el8.3.0+416+dee7bcef.noarch                                        11/54 
  验证    : perl-Net-SSLeay-1.88-1.module_el8.3.0+410+ff426aa3.x86_64                                            12/54 
  验证    : perl-URI-1.73-3.el8.noarch                                                                           13/54 
  验证    : perl-libnet-3.11-3.el8.noarch                                                                        14/54 
  验证    : protobuf-lite-3.5.0-13.el8.x86_64                                                                    15/54 
  验证    : checkpolicy-2.9-1.el8.x86_64                                                                         16/54 
  验证    : perl-Carp-1.42-396.el8.noarch                                                                        17/54 
  验证    : perl-Data-Dumper-2.167-399.el8.x86_64                                                                18/54 
  验证    : perl-Encode-4:2.97-3.el8.x86_64                                                                      19/54 
  验证    : perl-Errno-1.28-416.el8.x86_64                                                                       20/54 
  验证    : perl-Exporter-5.72-396.el8.noarch                                                                    21/54 
  验证    : perl-File-Path-2.15-2.el8.noarch                                                                     22/54 
  验证    : perl-File-Temp-0.230.600-1.el8.noarch                                                                23/54 
  验证    : perl-Getopt-Long-1:2.50-4.el8.noarch                                                                 24/54 
  验证    : perl-HTTP-Tiny-0.074-1.el8.noarch                                                                    25/54 
  验证    : perl-IO-1.38-416.el8.x86_64                                                                          26/54 
  验证    : perl-MIME-Base64-3.15-396.el8.x86_64                                                                 27/54 
  验证    : perl-PathTools-3.74-1.el8.x86_64                                                                     28/54 
  验证    : perl-Pod-Escapes-1:1.07-395.el8.noarch                                                               29/54 
  验证    : perl-Pod-Perldoc-3.28-396.el8.noarch                                                                 30/54 
  验证    : perl-Pod-Simple-1:3.35-395.el8.noarch                                                                31/54 
  验证    : perl-Pod-Usage-4:1.69-395.el8.noarch                                                                 32/54 
  验证    : perl-Scalar-List-Utils-3:1.49-2.el8.x86_64                                                           33/54 
  验证    : perl-Socket-4:2.027-3.el8.x86_64                                                                     34/54 
  验证    : perl-Storable-1:3.11-3.el8.x86_64                                                                    35/54 
  验证    : perl-Term-ANSIColor-4.06-396.el8.noarch                                                              36/54 
  验证    : perl-Term-Cap-1.17-395.el8.noarch                                                                    37/54 
  验证    : perl-Text-ParseWords-3.30-395.el8.noarch                                                             38/54 
  验证    : perl-Text-Tabs+Wrap-2013.0523-395.el8.noarch                                                         39/54 
  验证    : perl-Time-Local-1:1.280-1.el8.noarch                                                                 40/54 
  验证    : perl-Unicode-Normalize-1.25-396.el8.x86_64                                                           41/54 
  验证    : perl-constant-1.33-396.el8.noarch                                                                    42/54 
  验证    : perl-interpreter-4:5.26.3-416.el8.x86_64                                                             43/54 
  验证    : perl-libs-4:5.26.3-416.el8.x86_64                                                                    44/54 
  验证    : perl-macros-4:5.26.3-416.el8.x86_64                                                                  45/54 
  验证    : perl-parent-1:0.237-1.el8.noarch                                                                     46/54 
  验证    : perl-podlators-4.11-1.el8.noarch                                                                     47/54 
  验证    : perl-threads-1:2.21-2.el8.x86_64                                                                     48/54 
  验证    : perl-threads-shared-1.58-2.el8.x86_64                                                                49/54 
  验证    : policycoreutils-python-utils-2.9-9.el8.noarch                                                        50/54 
  验证    : python3-audit-3.0-0.17.20191104git1c2f876.el8.x86_64                                                 51/54 
  验证    : python3-libsemanage-2.9-3.el8.x86_64                                                                 52/54 
  验证    : python3-policycoreutils-2.9-9.el8.noarch                                                             53/54 
  验证    : python3-setools-4.3.0-2.el8.x86_64                                                                   54/54 

已安装:
  checkpolicy-2.9-1.el8.x86_64                                                                                         
  mariadb-connector-c-config-3.1.11-2.el8_3.noarch                                                                     
  mecab-0.996-1.module_el8.2.0+493+63b41e36.9.x86_64                                                                   
  mysql-8.0.21-1.module_el8.2.0+493+63b41e36.x86_64                                                                    
  mysql-common-8.0.21-1.module_el8.2.0+493+63b41e36.x86_64                                                             
  mysql-errmsg-8.0.21-1.module_el8.2.0+493+63b41e36.x86_64                                                             
  mysql-server-8.0.21-1.module_el8.2.0+493+63b41e36.x86_64                                                             
  perl-Carp-1.42-396.el8.noarch                                                                                        
  perl-Data-Dumper-2.167-399.el8.x86_64                                                                                
  perl-Digest-1.17-395.el8.noarch                                                                                      
  perl-Digest-MD5-2.55-396.el8.x86_64                                                                                  
  perl-Encode-4:2.97-3.el8.x86_64                                                                                      
  perl-Errno-1.28-416.el8.x86_64                                                                                       
  perl-Exporter-5.72-396.el8.noarch                                                                                    
  perl-File-Path-2.15-2.el8.noarch                                                                                     
  perl-File-Temp-0.230.600-1.el8.noarch                                                                                
  perl-Getopt-Long-1:2.50-4.el8.noarch                                                                                 
  perl-HTTP-Tiny-0.074-1.el8.noarch                                                                                    
  perl-IO-1.38-416.el8.x86_64                                                                                          
  perl-IO-Socket-IP-0.39-5.el8.noarch                                                                                  
  perl-IO-Socket-SSL-2.066-4.module_el8.3.0+410+ff426aa3.noarch                                                        
  perl-MIME-Base64-3.15-396.el8.x86_64                                                                                 
  perl-Mozilla-CA-20160104-7.module_el8.3.0+416+dee7bcef.noarch                                                        
  perl-Net-SSLeay-1.88-1.module_el8.3.0+410+ff426aa3.x86_64                                                            
  perl-PathTools-3.74-1.el8.x86_64                                                                                     
  perl-Pod-Escapes-1:1.07-395.el8.noarch                                                                               
  perl-Pod-Perldoc-3.28-396.el8.noarch                                                                                 
  perl-Pod-Simple-1:3.35-395.el8.noarch                                                                                
  perl-Pod-Usage-4:1.69-395.el8.noarch                                                                                 
  perl-Scalar-List-Utils-3:1.49-2.el8.x86_64                                                                           
  perl-Socket-4:2.027-3.el8.x86_64                                                                                     
  perl-Storable-1:3.11-3.el8.x86_64                                                                                    
  perl-Term-ANSIColor-4.06-396.el8.noarch                                                                              
  perl-Term-Cap-1.17-395.el8.noarch                                                                                    
  perl-Text-ParseWords-3.30-395.el8.noarch                                                                             
  perl-Text-Tabs+Wrap-2013.0523-395.el8.noarch                                                                         
  perl-Time-Local-1:1.280-1.el8.noarch                                                                                 
  perl-URI-1.73-3.el8.noarch                                                                                           
  perl-Unicode-Normalize-1.25-396.el8.x86_64                                                                           
  perl-constant-1.33-396.el8.noarch                                                                                    
  perl-interpreter-4:5.26.3-416.el8.x86_64                                                                             
  perl-libnet-3.11-3.el8.noarch                                                                                        
  perl-libs-4:5.26.3-416.el8.x86_64                                                                                    
  perl-macros-4:5.26.3-416.el8.x86_64                                                                                  
  perl-parent-1:0.237-1.el8.noarch                                                                                     
  perl-podlators-4.11-1.el8.noarch                                                                                     
  perl-threads-1:2.21-2.el8.x86_64                                                                                     
  perl-threads-shared-1.58-2.el8.x86_64                                                                                
  policycoreutils-python-utils-2.9-9.el8.noarch                                                                        
  protobuf-lite-3.5.0-13.el8.x86_64                                                                                    
  python3-audit-3.0-0.17.20191104git1c2f876.el8.x86_64                                                                 
  python3-libsemanage-2.9-3.el8.x86_64                                                                                 
  python3-policycoreutils-2.9-9.el8.noarch                                                                             
  python3-setools-4.3.0-2.el8.x86_64                                                                                   

完毕!
[root@localhost ~]# service mysqld start
Redirecting to /bin/systemctl start mysqld.service
[root@localhost ~]# service mysqld status
Redirecting to /bin/systemctl status mysqld.service
● mysqld.service - MySQL 8.0 database server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; disabled; vendor preset: disabled)
   Active: active (running) since Mon 2021-05-10 13:49:59 CST; 4s ago
  Process: 4305 ExecStartPost=/usr/libexec/mysql-check-upgrade (code=exited, status=0/SUCCESS)
  Process: 4177 ExecStartPre=/usr/libexec/mysql-prepare-db-dir mysqld.service (code=exited, status=0/SUCCESS)
  Process: 4152 ExecStartPre=/usr/libexec/mysql-check-socket (code=exited, status=0/SUCCESS)
 Main PID: 4261 (mysqld)
   Status: "Server is operational"
    Tasks: 39 (limit: 11210)
   Memory: 429.0M
   CGroup: /system.slice/mysqld.service
           └─4261 /usr/libexec/mysqld --basedir=/usr

5月 10 13:49:52 localhost.localdomain systemd[1]: Starting MySQL 8.0 database server...
5月 10 13:49:52 localhost.localdomain mysql-prepare-db-dir[4177]: Initializing MySQL database
5月 10 13:49:59 localhost.localdomain systemd[1]: Started MySQL 8.0 database server.
[root@localhost ~]# systemctl enable mysqld.service
Created symlink /etc/systemd/system/multi-user.target.wants/mysqld.service → /usr/lib/systemd/system/mysqld.service.
[root@localhost ~]# grep "password" /var/log/mysqld.log
grep: /var/log/mysqld.log: 没有那个文件或目录
[root@localhost ~]# grep "password" /var/log/mysql/mysqld.log
2021-05-10T05:49:54.001080Z 6 [Warning] [MY-010453] [Server] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
[root@localhost ~]# mysqladmin -uroot -p password 
Enter password: 
New password: 
Confirm new password: 
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
[root@localhost ~]# mysqladmin -uroot -p password 
Enter password: 
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: NO)'
[root@localhost ~]# 
[root@localhost ~]# mysqladmin -uroot -p password 
Enter password: 
New password: 
Confirm new password: 
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
[root@localhost ~]# mysql -uroot -p password      
Enter password: 
ERROR 1049 (42000): Unknown database 'password'
[root@localhost ~]# mysql -uroot -proot
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 12
Server version: 8.0.21 Source distribution

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> 
完毕!
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2023-08-10,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 首先,换yum源
  • wget -O CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo
  • 下面根据需求,安装对应版本的MySQL
    • 安装mysql5.6
      • 安装mysql5.7
        • 安装mysql8.0
          • 注意事项:
            • MySQL5.7不能修改简单密码的问题
            相关产品与服务
            云数据库 MySQL
            腾讯云数据库 MySQL(TencentDB for MySQL)为用户提供安全可靠,性能卓越、易于维护的企业级云数据库服务。其具备6大企业级特性,包括企业级定制内核、企业级高可用、企业级高可靠、企业级安全、企业级扩展以及企业级智能运维。通过使用腾讯云数据库 MySQL,可实现分钟级别的数据库部署、弹性扩展以及全自动化的运维管理,不仅经济实惠,而且稳定可靠,易于运维。
            领券
            问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档