centos8安装mysql_CentOS8或RHEL8系统如何安装MySQL 8.0

请关注本头条号,每天坚持更新原创干货技术文章。

如需学习视频,请在微信搜索公众号“智传网优”直接开始自助视频学习

1. 前言

本文主要介绍如何在CentOS8或者RHEL8服务器上安装MySQL 8.0。如果你是RHEL8的新手,您可以在我之前的文章Red Hat Enterprise Linux 8 (RHEL8)的新特性和评论中找到所有的RHEL8新特性。MySQL是一个多线程、多用户的SQL数据库服务器。它由MySQL服务器守护进程、mysqld和许多客户端程序组成。

40fdb15457a20b74ee2a852f1afb1535.png

CentOS8或RHEL8系统如何安装MySQL 8.0

1.1 MySQL 8.0增强特性

RHEL 8是随MySQL 8.0发布的,它有以下新特性:

  • 增强的JSON的功能。
  • MySQL 8.0支持角色。角色是特权的集合。
  • 它合并了一个事务性数据字典,用来存储关于数据库对象的信息。
  • 是否支持公共表表达式——递归和非递归
  • 支持窗口函数,它使用相关行对查询中的每一行执行计算。
  • 它提供了InnoDB,支持NOWAIT和跳过锁定选项锁定读语句。
58e7e4ac9f06038fd1a6c77455e4974e.png

MySQL 8.0增强特性

1.2 MySQL 8.0默认的身份验证插件

注意,MySQL 8.0服务器分布式RHEL 8配置为使用mysql_native_password作为默认身份验证插件,因为客户端工具和库在RHEL 8 caching_sha2_password方法是不相容的,默认情况下使用的上游MySQL 8.0版本。

对于MariaDB用户,我写了一篇关于MariaDB 10.3安装在RHEL8或CentOS8上的文章如下:

2. 在CentOS8或RHEL8上安装Mysql 8.0

按照这里提供的步骤在RHEL8或者CentOS8上安装MySQL 8.0。

b79d539a791c09167b991adbe9186f04.png

在CentOS8或RHEL8上安装Mysql 8.0

2.1 步骤1:更新系统

确保您的系统已更新。

sudo yum update

2.2 步骤2:在RHEL8或CentOS8上安装MySQL 8.0

mysql 8.0包在AppStream存储库中可用,可以通过运行以下命令来安装:

sudo dnf install @mysql:8.0

提示时确认安装

Transaction SummaryInstall 7 PackagesTotal download size: 35 MInstalled size: 229 MIs this ok [y/N]: y

将安装以下软件包

Installed:mysql-8.0.12-6.el8+1923+5642a751.x86_64 mysql-server-8.0.12-6.el8+1923+5642a751.x86_64 mecab-0.996-1.el8+1521+e4919bed.9.x86_64 mysql-common-8.0.12-6.el8+1923+5642a751.x86_64 mariadb-connector-c-config-3.0.6-2.el8.noarch protobuf-lite-3.5.0-7.el8.x86_64 mysql-errmsg-8.0.12-6.el8+1923+5642a751.x86_64Complete!

2.3 步骤3: 在RHEL8或CentOS8上配置MySQL 8.0

f8243a28b9fc375955098bf5bca42527.png

在RHEL8或CentOS8上配置MySQL 8.0

设置MySQL 8.0开机自启动sudo systemctl enable --now mysql

检查服务状态:

sudo systemctl status mysqld

● mysqld.service - MySQL 8.0 database server

Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)

Active: active (running) since Wed 2018-12-05 15:32:50 EST; 16s ago

Process: 4387 ExecStartPost=/usr/libexec/mysql-check-upgrade (code=exited, status=0/SUCCESS)

Process: 4262 ExecStartPre=/usr/libexec/mysql-prepare-db-dir mysqld.service (code=exited, status=0/SUCCESS)

Process: 4238 ExecStartPre=/usr/libexec/mysql-check-socket (code=exited, status=0/SUCCESS)

Main PID: 4345 (mysqld)

Status: "SERVER_OPERATING"

Tasks: 37 (limit: 5056)

Memory: 358.9M

CGroup: /system.slice/mysqld.service

└─4345 /usr/libexec/mysqld --basedir=/usr

Dec 05 15:32:42 rhel8.localdomain systemd[1]: Starting MySQL 8.0 database server…

Dec 05 15:32:42 rhel8.localdomain mysql-prepare-db-dir[4262]: Initializing MySQL database

Dec 05 15:32:50 rhel8.localdomain systemd[1]: Started MySQL 8.0 database server.

启动服务后,运行命令mysql_secure_installation来加强MySQL数据库服务器。

mysql_secure_installation

Securing the MySQL server deployment.

Connecting to MySQL using a blank password.

VALIDATE PASSWORD COMPONENT 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 component?

Press y|Y for Yes, any other key for No:

Please set the password for root here.

New password:

Re-enter new password:

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) : y

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) : y

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) : y

  • 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) : y

Success.

All done!

以上操作确保你:

  • 设置数据库root用户密码
  • 删除匿名用户
  • 不允许root用户远程登录
  • 删除测试数据库并访问它

完成后,使用root用户测试访问

mysql -u root -p

Enter password:

Welcome to the MySQL monitor. Commands end with ; or g.

Your MySQL connection id is 11

Server version: 8.0.12 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> SELECT VERSION();

+-----------+

| VERSION() |

+-----------+

| 8.0.12 |

+-----------+

1 row in set (0.00 sec)

mysql> QUIT

Bye

3. 总结

通过本文您现在已经在RHEL8或CentOS8毓上安装了MySQL 8.0数据库服务器。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值