Redhat 8.7 安装Mysql 8.0.34步骤(超级详细)

本文详细介绍了如何在RedHatEnterpriseLinux8.7上下载并安装MySQLYumRepository,禁用默认MySQL模块,设置临时密码,以及允许远程登录。过程包括查看系统版本、安装社区版MySQL服务器、启用系统服务和管理用户权限。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

查看Redhat 版本

[root@node1-221 ~]# cat /etc/redhat-release 
Red Hat Enterprise Linux release 8.7 (Ootpa)

下载MySQL Yum Repository

下载MySQL源官网地址:https://dev.mysql.com/downloads/repo/yum/
根据系统版本选择下载相应的MySQL Yum源
在这里插入图片描述

安装mysql

[root@node1-221 ~]# yum install mysql80-community-release-el8-7.noarch.rpm
[root@node1-221 ~]# yum repolist
Updating Subscription Management repositories.
Unable to read consumer identity

This system is not registered with an entitlement server. You can use subscription-manager to register.

repo id                                                                                         repo name
appstream                                                                                       appstream
baseos                                                                                          baseos
mysql-connectors-community                                                                      MySQL Connectors Community
mysql-tools-community                                                                           MySQL Tools Community
mysql80-community                                                                               MySQL 8.0 Community Server
[root@node1-221 ~]# yum repolist| grep mysql
mysql-connectors-community              MySQL Connectors Community
mysql-tools-community                   MySQL Tools Community
mysql80-community                       MySQL 8.0 Community Server

Disabling the Default MySQL Module

(EL8 systems only) EL8-based systems such as RHEL8 and Oracle Linux 8 include a MySQL module that is enabled by default. Unless this module is disabled, it masks packages provided by MySQL repositories. To disable the included module and make the MySQL repository packages visible, use the following command (for dnf-enabled systems, replace yum in the command with dnf):
EL8系统,需要禁掉默认的MySQL仓库

[root@node1-221 ~]# yum module disable mysql

安装MySQL

[root@node1-221 ~]# yum install mysql-community-server

启动MySQL

[root@node1-221 ~]# systemctl start mysqld
[root@node1-221 ~]# systemctl status mysqld
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Fri 2023-08-11 14:44:16 CST; 1s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 14401 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 14473 (mysqld)
   Status: "Server is operational"
    Tasks: 38 (limit: 24850)
   Memory: 454.2M
   CGroup: /system.slice/mysqld.service
           └─14473 /usr/sbin/mysqld

Aug 11 14:44:10 node1-221 systemd[1]: Starting MySQL Server...
Aug 11 14:44:16 node1-221 systemd[1]: Started MySQL Server.

查看MySQL临时密码

通过日志文件MySQL初始密码
MySQL的临时密码存放在/var/log/mysqld.log文件下

[root@node1-221 ~]# grep 'temporary password' /var/log/mysqld.log
2023-08-11T06:44:12.606853Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: Ig3PKBN3z.36

进入MySQL,修改临时密码

[root@node1-221 ~]# 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.34

Copyright (c) 2000, 2023, 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> alter user 'root'@'localhost' identified by 'Lab123!@#';
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye

使用新密码登陆MySQL

[root@node1-221 ~]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 14
Server version: 8.0.34 MySQL Community Server - GPL

Copyright (c) 2000, 2023, 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> 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
mysql> select host,user from user;
+-----------+------------------+
| host      | user             |
+-----------+------------------+
| localhost | mysql.infoschema |
| localhost | mysql.session    |
| localhost | mysql.sys        |
| localhost | root             |
+-----------+------------------+
4 rows in set (0.00 sec)
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.00 sec)

可以正常通过客户端远程登陆数据库了
在这里插入图片描述

### MySQL 8.0.34 版本的相关信息 #### 下载地址 MySQL 官方网站提供了各个版本的下载链接,用户可以根据操作系统选择适合的安装包。对于 MySQL 8.0.34 的具体下载页面,可以通过访问以下 URL 获取: [https://dev.mysql.com/downloads/mysql/](https://dev.mysql.com/downloads/mysql/) 在该页面中,可以选择具体的版本号以及对应的平台(如 Linux RPM、Windows MSI 或其他)。如果需要离线安装文件,则可以找到 `.tar.gz` 压缩包或者针对 RedHat/CentOS 的 RPM 包。 #### 更新日志概述 MySQL 8.0.34 是一个小版本更新,主要集中在性能优化、安全增强和功能改进方面。以下是部分重要变更: 1. **安全性提升**: - 默认启用了更严格的身份验证机制[^2]。 - 提供了新的加密算法支持,增强了数据传输的安全性。 2. **兼容性调整**: - 如果某些应用依赖于旧版 MySQL 身份验证方式,可以在配置过程中启用 `Use Legacy Authentication Method` 来保持向后兼容性[^2]。 3. **错误修复**: - 解决了一些潜在的内存泄漏问题,尤其是在高并发场景下运行时可能引发的服务中断情况。 - 针对 InnoDB 存储引擎中的事务处理逻辑进行了微调,减少了死锁发生的概率。 4. **新特性引入**: - 扩展了 JSON 数据类型的查询能力,新增了几种函数用于解析复杂嵌套结构的数据集。 - 对全文索引的支持范围进一步扩大,允许更多语言环境下的分词操作得以实现。 #### 升级流程说明 当从较低版本(例如 MySQL 8.0.28)迁移到目标版本时,建议遵循官方文档推荐的最佳实践步骤完成整个过程。通常涉及以下几个环节的操作命令如下所示: ```bash # 步骤一:卸载现有组件并保留数据库目录内容不变 yum remove mysql-community-server mysql-community-client # 步骤二:导入最新的 GPG 密钥以验证软件包真实性 rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022 # 步骤三:逐一安装所需模块直至服务器端服务启动成功为止 rpm -ivh mysql-community-client-plugins-8.0.34-1.el7.x86_64.rpm \ mysql-community-common-8.0.34-1.el7.x86_64.rpm \ mysql-community-libs-8.0.34-1.el7.x86_64.rpm \ mysql-community-libs-compat-8.0.34-1.el7.x86_64.rpm \ --nodeps mysql-community-devel-8.0.34-1.el7.x86_64.rpm \ mysql-community-client-8.0.34-1.el7.x86_64.rpm \ mysql-community-server-8.0.34-1.el7.x86_64.rpm service mysqld start && systemctl enable mysqld.service ``` 以上脚本适用于基于 RHEL 系列发行版的操作系统环境中执行自动化部署任务。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值