阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

如何在CentOS 7/6,RHEL 7/6和Fedora 28/27/26上安装MySQL 8.0

447次阅读
没有评论

共计 5535 个字符,预计需要花费 14 分钟才能阅读完成。

MySQL 是一个免费的开源数据库管理系统,常用于 Web 应用程序中,用于存储和检索记录和信息。

MySQL 最初由 MYSQL AB 开发,现在由 Oracle Corporation 拥有。它是 Linux 操作系统的主要数据库应用程序,直到 MySQL 的一个分支 MariaDB 才出现。

在本文中,我们将讨论如何在 CentOS 7/6,RHEL 7/ 6 和 Fedora 28/27/26 上安装 MySQL 8.0 的基本过程。

添加 MySQL 存储库

MySQL 不再通过基本操作系统映像分发或在 OS 存储库中可用。因此,您需要添加 MySQL 的官方存储库来安装 MySQL 社区服务器。

### CentOS 7 / RHEL 7 ###

rpm -ivh https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm

### CentOS 6 / RHEL 6 ###

rpm -ivh https://dev.mysql.com/get/mysql80-community-release-el6-1.noarch.rpm

### Fedora 28 ###

rpm -ivh https://dev.mysql.com/get/mysql80-community-release-fc28-1.noarch.rpm

### Fedora 27 ###

rpm -ivh https://dev.mysql.com/get/mysql80-community-release-fc27-1.noarch.rpm

### Fedora 26 ###

rpm -ivh https://dev.mysql.com/get/mysql80-community-release-fc26-1.noarch.rpm

确保使用以下命令添加并启用了 MySQL 存储库。

yum repolist all | grep mysql | grep enabled

输出:可能看起来像。

mysql-connectors-community/x86_64  MySQL Connectors Community     enabled:    51
mysql-tools-community/x86_64       MySQL Tools Community          enabled:    63
mysql80-community/x86_64           MySQL 8.0 Community Server     enabled:    17

安装 MySQL Community Server

Oracle 目前提供稳定版本(v8.0 和 v5.7)。您可以选择要在计算机上安装的那个。

安装 MySQL 8.0

在 CentOS/RHEL 中使用 yum 命令,在 Fedora 中使用 dnf 命令安装最新的稳定版 MySQL。

### CentOS 7/6 & RHEL 7/6 ###

yum -y install mysql-community-server

### Fedora 28/27/26 ###

dnf -y install mysql-community-server

安装 MySQL 5.7

如果您想尝试旧版本的 MySQL,请在您的计算机上安装 MySQL 5.7。

### CentOS 7/6 & RHEL 7/6 ###

yum -y install mysql-community-server  --disablerepo=mysql80-community --enablerepo=mysql57-community

### Fedora 28/27/26 ###

dnf -y install mysql-community-server  --disablerepo=mysql80-community --enablerepo=mysql57-community

启动 MySQL 服务

安装 MySQL 后,可以使用以下命令启动 MySQL 服务器。

### CentOS 7 / RHEL 7 / Fedora 28/27/26 ###

systemctl start mysqld

### CentOS 6 / RHEL 6 ###

service mysqld start

在系统启动时启用 MySQL 服务器。

### CentOS 7 / RHEL 7 / Fedora 28/27/26 ###

systemctl enable mysqld

### CentOS 6 / RHEL 6 ###

chkconfig mysqld on

使用以下命令验证是否已启动 MySQL 服务器。

### CentOS 7 / RHEL 7 / Fedora 28/27/26 ###

systemctl status mysqld

### CentOS 6 / RHEL 6 ###

service mysqld status

输出:

CentOS 7 / RHEL 7 / Fedora:

 mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Fri 2018-12-04 19:19:36 EDT; 21s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
 Main PID: 8452 (mysqld)
   Status: "SERVER_OPERATING"
   CGroup: /system.slice/mysqld.service
           └─8452 /usr/sbin/mysqld

Dec 04 19:19:23 server.itzgeek.local systemd[1]: Starting MySQL Server...
Dec 04 19:19:36 server.itzgeek.local systemd[1]: Started MySQL Server.

CentOS 6 / RHEL 6 :

mysqld (pid 2258) is running...

MySQL 服务器 安全设置

在 CentOS/RHEL/Fedora 中,可以在 /var/log/mysqld.log 中找到初始的 MySQL root 密码。您可以使用以下命令从日志文件中获取密码。

cat /var/log/mysqld.log | grep -i 'temporary password'

输出:

2017-11-25T07:02:29.549979Z 1 [Note] A temporary password is generated for root@localhost: Ed*Sn(6R9q0h

现在,您需要运行 mysql_secure_installation 来保护 MySQL 安装。此命令负责设置 root 密码,删除匿名用户,远程禁止 root 登录等。

mysql_secure_installation

输出:

Securing the MySQL server deployment.

Enter password for user root:  <== Enter Root password taken from previous step

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

New password: <== Enter New Root Password

Re-enter new password: <== Re-Enter New Root Password 
VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?

Press y|Y for Yes, any other key for No: No <== Already high secure enough
Using existing password for root.
Change the password for root ? ((Press y|Y for Yes, any other key for No) : no <== Since the password is already changed in previous step, type no.

 ... skipping.
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : yes <== Remove Anonymous user
Success.


Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : yes <== Disable remote root login
Success.

By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.


Remove test database and access to it? (Press y|Y for Yes, any other key for No) : yes <== Remove test database
 - Dropping test database...
Success.

 - Removing privileges on test database...
Success.

Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : yes <== Reload Privilege
Success.

All done!

使用 MySQL 服务器

使用 root 用户及其密码登录 MySQL 服务器。

mysql -u root -p

输出:
MySQL 8.0:

Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 8.0.11 MySQL Community Server - GPL

Copyright (c) 2000, 2018, 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>

MySQL 5.7:

Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.22 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, 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>

安装 phpMyAdmin

phpMyAdmin 是一个基于 Web 的开源管理工具,用于管理 MySQL 和 MariaDB 数据库。按照以下链接,根据您的操作系统安装和配置 phpMyAdmin。

在 Fedora 27/Fedora 26/25/24 上安装 phpMyAdmin 见 https://www.linuxidc.com/Linux/2018-12/155691.htm

如何在 CentOS 7/RHEL 7 上安装 phpMyAdmin 见 https://www.linuxidc.com/Linux/2018-12/155690.htm

正文完
星哥玩云-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-22发表,共计5535字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中

星哥玩云

星哥玩云
星哥玩云
分享互联网知识
用户数
4
文章数
19348
评论数
4
阅读量
7802936
文章搜索
热门文章
开发者必备神器:阿里云 Qoder CLI 全面解析与上手指南

开发者必备神器:阿里云 Qoder CLI 全面解析与上手指南

开发者必备神器:阿里云 Qoder CLI 全面解析与上手指南 大家好,我是星哥。之前介绍了腾讯云的 Code...
星哥带你玩飞牛NAS-6:抖音视频同步工具,视频下载自动下载保存

星哥带你玩飞牛NAS-6:抖音视频同步工具,视频下载自动下载保存

星哥带你玩飞牛 NAS-6:抖音视频同步工具,视频下载自动下载保存 前言 各位玩 NAS 的朋友好,我是星哥!...
云服务器部署服务器面板1Panel:小白轻松构建Web服务与面板加固指南

云服务器部署服务器面板1Panel:小白轻松构建Web服务与面板加固指南

云服务器部署服务器面板 1Panel:小白轻松构建 Web 服务与面板加固指南 哈喽,我是星哥,经常有人问我不...
我把用了20年的360安全卫士卸载了

我把用了20年的360安全卫士卸载了

我把用了 20 年的 360 安全卫士卸载了 是的,正如标题你看到的。 原因 偷摸安装自家的软件 莫名其妙安装...
星哥带你玩飞牛NAS-3:安装飞牛NAS后的很有必要的操作

星哥带你玩飞牛NAS-3:安装飞牛NAS后的很有必要的操作

星哥带你玩飞牛 NAS-3:安装飞牛 NAS 后的很有必要的操作 前言 如果你已经有了飞牛 NAS 系统,之前...
阿里云CDN
阿里云CDN-提高用户访问的响应速度和成功率
随机文章
升级自动部署更新SSL证书系统、申请godaddy的APIKEY

升级自动部署更新SSL证书系统、申请godaddy的APIKEY

升级自动部署更新 SSL 证书系统、申请 godaddy 的 APIKEY 公司之前花钱购买的 ssl 证书快...
国产开源公众号AI知识库 Agent:突破未认证号限制,一键搞定自动回复,重构运营效率

国产开源公众号AI知识库 Agent:突破未认证号限制,一键搞定自动回复,重构运营效率

国产开源公众号 AI 知识库 Agent:突破未认证号限制,一键搞定自动回复,重构运营效率 大家好,我是星哥,...
飞牛NAS中安装Navidrome音乐文件中文标签乱码问题解决、安装FntermX终端

飞牛NAS中安装Navidrome音乐文件中文标签乱码问题解决、安装FntermX终端

飞牛 NAS 中安装 Navidrome 音乐文件中文标签乱码问题解决、安装 FntermX 终端 问题背景 ...
把小米云笔记搬回家:飞牛 NAS 一键部署,小米云笔记自动同步到本地

把小米云笔记搬回家:飞牛 NAS 一键部署,小米云笔记自动同步到本地

把小米云笔记搬回家:飞牛 NAS 一键部署,小米云笔记自动同步到本地 大家好,我是星哥,今天教大家在飞牛 NA...
星哥带你玩飞牛NAS硬件02:某鱼6张左右就可拿下5盘位的飞牛圣体NAS

星哥带你玩飞牛NAS硬件02:某鱼6张左右就可拿下5盘位的飞牛圣体NAS

星哥带你玩飞牛 NAS 硬件 02:某鱼 6 张左右就可拿下 5 盘位的飞牛圣体 NAS 前言 大家好,我是星...

免费图片视频管理工具让灵感库告别混乱

一言一句话
-「
手气不错
让微信公众号成为 AI 智能体:从内容沉淀到智能问答的一次升级

让微信公众号成为 AI 智能体:从内容沉淀到智能问答的一次升级

让微信公众号成为 AI 智能体:从内容沉淀到智能问答的一次升级 大家好,我是星哥,之前写了一篇文章 自己手撸一...
星哥带你玩飞牛 NAS-10:备份微信聊天记录、数据到你的NAS中!

星哥带你玩飞牛 NAS-10:备份微信聊天记录、数据到你的NAS中!

星哥带你玩飞牛 NAS-10:备份微信聊天记录、数据到你的 NAS 中! 大家对「数据安全感」的需求越来越高 ...
浏览器自动化工具!开源 AI 浏览器助手让你效率翻倍

浏览器自动化工具!开源 AI 浏览器助手让你效率翻倍

浏览器自动化工具!开源 AI 浏览器助手让你效率翻倍 前言 在 AI 自动化快速发展的当下,浏览器早已不再只是...
星哥带你玩飞牛NAS硬件03:五盘位+N5105+双网口的成品NAS值得入手吗

星哥带你玩飞牛NAS硬件03:五盘位+N5105+双网口的成品NAS值得入手吗

星哥带你玩飞牛 NAS 硬件 03:五盘位 +N5105+ 双网口的成品 NAS 值得入手吗 前言 大家好,我...
星哥带你玩飞牛NAS-12:开源笔记的进化之路,效率玩家的新选择

星哥带你玩飞牛NAS-12:开源笔记的进化之路,效率玩家的新选择

星哥带你玩飞牛 NAS-12:开源笔记的进化之路,效率玩家的新选择 前言 如何高效管理知识与笔记,已经成为技术...