云网牛站
所在位置:首页 > Linux云数据库 > 在RHEL 8系统上安装MySQL 8.0的步骤

在RHEL 8系统上安装MySQL 8.0的步骤

2018-12-26 10:00:37作者:秦风稿源:云网牛站

本文介绍在RedHat Enterprise Linux 8(RHEL 8)服务器上安装MySQL 8.0的方法,请注意,随RHEL 8一起发布的MySQL 8.0配置为使用mysql_native_password作为默认身份验证插件,因为RHEL 8中的客户端工具和库与caching_sha2_password不兼容,后者在上游MySQL 8.0版本中默认使用。安装MySQL 8.0难度不大,以下是具体步骤。

 

第1步:更新RHEL 8系统

确保RHEL 8系统已经更新,请使用以下命令:

sudo yum update

 

第2步:在RHEL 8系统上安装MySQL 8.0

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

sudo yum install @mysql:8.0

2、出现提示时确认安装,请输入y:

Transaction Summary

Install  7 Packages

Total download size: 35 M

Installed size: 229 M

Is this ok [y/N]: y

3、将安装以下包,直到自动完成:

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_64

Complete!

 

第3步:在RHEL 8上配置MySQL 8.0

1、激活mysqld服务:

sudo systemctl enable --now mysql

2、确认服务状态:

$ 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-26 8:32:50; 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 26 8:32:42 rhel8.localdomain systemd[1]: Starting MySQL 8.0 database server...

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

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

3、启动服务后,运行命令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: <ENTER NEW PASSWORD>

Re-enter new password: <CONFIRM 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用户远程登录。

删除测试数据库并访问它。

4、完成后,使用root用户测试访问权限:

$ mysql -u root -p

在RHEL 8系统上安装MySQL 8.0的步骤

至此,已经在RHEL 8上安装了MySQL 8.0数据库,你可以正常的使用它了。

 

相关主题

在阿里云服务器CentOS 7上安装部署MySql 8.0

精选文章
热门文章