千家信息网

怎么在Centos7中安装 Mysql8

发表于:2026-11-02 作者:千家信息网编辑
千家信息网最后更新 2026年11月02日,这篇文章给大家介绍怎么在Centos7中安装 Mysql8,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。Mysql8新特性:Mysql从5.x版本直接跳跃到8.x,我个人是这么看
千家信息网最后更新 2026年11月02日怎么在Centos7中安装 Mysql8

这篇文章给大家介绍怎么在Centos7中安装 Mysql8,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。

Mysql8新特性:

Mysql从5.x版本直接跳跃到8.x,我个人是这么看的:

MySQL 5.5 -> MySQL 5
MySQL 5.6 -> MySQL 6
MySQL 5.7 -> MySQL 7
MySQL 8.0 -> MySQL 8

当然也有可能是Mysql6、7内部难产了-_-,自从被Oracle收购后,活力依旧在,mysql8有以下新特性:

  • MySQL 文档存储

  • 默认 utf8mb4 编码

  • JSON 增强

  • CTEs(译者注:Common Table Expresssions 公共表格表达式)

  • 窗口函数

  • 降序索引

  • 更好的优化器消费模型

  • MySQL 服务器组件

  • GIS(译者注:Geographic Information System 地理信息系统) 提升

  • InnoDB 引擎的 NO WAIT 和 SKIP \ LOCKED 选项

Centos7 Mysql8安装步骤:

1、设置mysql源

首先,您需要在MySQL提供的系统中启用MySQL yum存储库。 根据您的操作系统版本执行以下命令之一,这里我们选择CentOS 7 / RHEL 7的源

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

###在CentOS 7 / RHEL 7系统上###

rpm -Uvh https://repo.mysql.com/mysql80-community-release-el7-3.noarch.rpm

###在CentOS 7 / RHEL 6系统上###

rpm -Uvh https://repo.mysql.com/mysql80-community-release-el6-3.noarch.rpm

###在Fedora 30系统上###

rpm -Uvh https://repo.mysql.com/mysql80-community-release-fc30-1.noarch.rpm

###在Fedora 29系统上###

rpm -Uvh https://repo.mysql.com/mysql80-community-release-fc29-2.noarch.rpm

###在Fedora 28系统上###

rpm -Uvh https://repo.mysql.com/mysql80-community-release-fc28-2.noarch.rpm

2、安装MySQL Community Server

MySQL yum存储库包含用于多个MySQL版本的多个存储库配置。 因此,首先禁用mysql repo文件中的所有存储库

?

1

sed -i 's/enabled=1/enabled=0/' /etc/yum.repos.d/mysql-community.repo

启用centos mysql8版本

?

1

2

3

4

## CentOS & RedHat 版本

yum --enablerepo=mysql80-community install mysql-community-server

## Fedora Systems 版本

dnf --enablerepo=mysql80-community install mysql-community-server

3、启动MySQL服务

?

1

service mysqld start

使用Systemd

?

1

systemctl start mysqld.service

4、查找MySQL root密码

安装MySQL 8.0后,将为MySQL根用户创建一个临时密码。 您可以在日志文件中找到生成的临时密码。密码文件位置:/var/log/mysqld.log

?

1

grep "A temporary password" /var/log/mysqld.log

5、重置root密码

首次安装MySQL后,执行mysql_secure_installation命令以保护MySQL服务器,包含重置密码步骤

?

1

mysql_secure_installation

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

Enter password for user root:

The existing password for the user account root has expired. Please set a new password.

New password:

Re-enter new password:

Remove anonymous users? (Press y|Y for Yes, any other key for No) : y

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y

Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y

6、mysql 服务加入开机启动项,并启动mysql进程

?

1

2

3

### Using Systemd

systemctl enable mysqld.service

systemctl restart mysqld.service

7、开放3306端口

如果服务器开启了防火墙,记得开启3306端口

?

1

2

3

4

5

6

7

8

systemctl enable iptables

systemctl start iptables

vim /etc/sysconfig/iptables

##规则中加入

-A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT

##重启防火墙

systemctl enable iptables.service

systemctl start iptables.service

如果使用的腾讯云的服务器,一定记得开启安全组里的端口

附mysql常用命令:

登录mysql

?

1

mysql -u username -p

启动mysql

?

1

systemctl start mysqld.service

结束mysql

?

1

systemctl stop mysqld.service

重启mysql

?

1

systemctl restart mysqld.service

开机自启

?

1

systemctl enable mysqld.service

关于怎么在Centos7中安装 Mysql8就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。

原文链接:https://cloud.tencent.com/developer/article/1649952

系统 密码 版本 服务 存储 服务器 命令 文件 端口 中安 内容 多个 更多 步骤 特性 译者 防火墙 帮助 防火 不错 数据库的安全要保护哪些东西 数据库安全各自的含义是什么 生产安全数据库录入 数据库的安全性及管理 数据库安全策略包含哪些 海淀数据库安全审计系统 建立农村房屋安全信息数据库 易用的数据库客户端支持安全管理 连接数据库失败ssl安全错误 数据库的锁怎样保障安全 互联网络科技 广东猪兼强互联网科技有限公司 互联网科技行业发展 科技互联网政务服务 互联网科技有限公司图片 腾讯阿里互联网科技 互联网科技媒体 碳银互联网科技 博兴的互联网电子科技公司 江苏南京365互联网科技 来此购互联网科技有限公司 互联网为啥属于高科技 乌苏新华互联网科技做什么的 燊美集互联网科技有限公司 为客找房互联网科技公司怎么样 郑州欣桑互联网科技有限公司 互联网科技创业计划的风险分析 恒生互联网科技趋势 互联网企业和网络科技有限公司 中国主要互联网科技公司 互联网科技园 四川狮子座互联网科技 互联网科技股午盘股票涨跌 安控科技rtu产品工业互联网 内蒙古九一互联网科技 深圳市罗太互联网科技有限公司 中天科技中国工业互联网 互联网时代科技型公司的机会 重庆科技产业互联网有哪些 优雇互联网科技有限公司
0