在 CentOS 7 中安装 MySQL 8 Yum 存储库

从 MySQL 官方网站下载并安装 MySQL yum 存储库。

[root@mysql-server ~]# rpm -ivh https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm

为 MySQL yum 存储库构建缓存。

[root@mysql-server ~]# yum makecache fast

保护 MySQL Server 8 社区版

要配置和保护我们的 MySQL 数据库实例,我们可以使用 mysql_secure_installation 命令。
我们还需要使用临时密码为 root 用户设置新密码。

[root@mysql-server ~]# mysql_secure_installation
Securing the MySQL server deployment.
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:
The 'validate_password' component is installed on the server.
The subsequent steps will run with the existing configuration
of the component.
Using existing password for root.
Estimated strength of the password: 100
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : Y
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 用户身份使用 mysql 命令连接 MySQL 数据库服务器。

[root@mysql-server ~]# 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.16 MySQL Community Edition - GPL
Copyright (c) 2000, 2019, 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> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.01 sec)
mysql>

我们已经在 CentOS 7 服务器上成功安装了 MySQL Server 8 社区版(Community Edition)。

www. On IT Road .com

在 CentOS 7 上安装 MySQL Server 8 社区版

我们已经添加了 MySQL yum 存储库,现在我们可以使用 yum 命令安装 MySQL Server 8 Community Edition 和相关软件包。

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

MySQL 服务由安装程序自动启用。
因此,我们只需要启动 mysqld.service 一次。

[root@mysql-server ~]# systemctl start mysqld.service

首次启动时,MySQL 服务会在 /var/log/mysqld.log 文件中生成一个临时密码。

使用以下命令检索此密码。

[root@mysql-server ~]# grep 'temporary password' /var/log/mysqld.log
2019-06-24T14:23:17.605740Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: B4gqaLFg6p_Y

记下这个密码,我们稍后会用到。

在 CentOS 7 上安装 MySQL Server 8 社区版

MySQL Server Community Edition (CE) 是世界上最流行的开源数据库服务器的免费版本。
它是在 GPL 许可下分发的,并由一个庞大而活跃的开源开发人员社区提供支持。
还有一个商业版的 MySQL 服务器,由 Oracle Corporation 开发和维护。

在本文中,我们将在 CentOS 7 服务器上安装 MySQL 服务器 8 社区版。

日期:2020-09-17 00:11:10 来源:oir作者:oir