CentOS 8 | CentOS 7系统安装MariaDB 10.5详细过程

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
RDS MySQL Serverless 高可用系列,价值2615元额度,1个月
云数据库 RDS PostgreSQL,高可用系列 2核4GB
简介: MariaDB是具有巨大社区支持的MySQL关系数据库管理系统的社区分支。MariaDB 10.5的稳定版本已于2020年6月发布,并且将受支持直到2025年6月。本文简单说说CentOS 8 | CentOS 7系统安装MariaDB 10.5的过程。

在本文中将简单介绍如何在CentOS 8 | CentOS 7系统中安装MariaDB 10.5。

MariaDB是具有巨大社区支持的MySQL关系数据库管理系统的社区分支。MariaDB 10.5的稳定版本已于2020年6月发布,并且将受支持直到2025年6月。

如果您要从另一个版本(如10.4)进行升级,请查看官方升级指南,并注意两个版本的MariaDB之间的差异。这对于已使用自定义变量调整数据库并确保交易效率的生产用例非常重要。

MariaDB团队为维护的存储库提供了针对各种Linux版本的最新软件包。对于CentOS,我们将使用YUM存储库。下面简单说说CentOS 8 | CentOS 7系统安装MariaDB 10.5详细过程。

步骤1:添加MariaDB YUM存储库

运行以下命令以将MariaDB提供的存储库添加到CentOS服务器。

将存储库添加到CentOS 8系统:

sudo tee /etc/yum.repos.d/mariadb.repo<[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.5/centos8-amd64
module_hotfixes=1
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
EOF

将存储库添加到CentOS 7系统:

sudo tee /etc/yum.repos.d/mariadb.repo<[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.5/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
EOF

通过更新缓存来确认存储库正在工作。

sudo yum makecache

列出可用的存储库:

$ sudo yum repolist
repo id repo name
AppStream CentOS-8 - AppStream
BaseOS CentOS-8 - Base
extras CentOS-8 - Extras
mariadb MariaDB

步骤2:CentOS 8 | CentOS 7系统安装MariaDB 10.5

添加存储库并确认其正常运行后,可以继续在CentOS 8 / CentOS 7 Linux服务器上安装MariaDB 10.5。

sudo yum install MariaDB-server MariaDB-client

运行以上命令可以检查要安装的软件包列表,并同意是否可以安装。

.....
Installing weak dependencies:
perl-IO-Socket-IP noarch 0.39-5.el8 AppStream 47 k
perl-IO-Socket-SSL noarch 2.066-4.el8 AppStream 297 k
perl-Mozilla-CA noarch 20160104-7.el8 AppStream 15 k
Enabling module streams:
perl 5.26
perl-DBI 1.641

================================================================================================================================================================
Install 54 Packages

Total download size: 67 M
Installed size: 298 M
Is this ok [y/N]: y

在出现提示时,还需同意导入GPG密钥。

.....
Importing GPG key 0x1BB943DB:
Userid : "MariaDB Package Signing Key package-signing-key@mariadb.org"
Fingerprint: 1993 69E5 404B D5FC 7D2F E43B CBCB 082A 1BB9 43DB
From : https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
Is this ok [y/N]: y

RPM软件包详细信息如下:

$ rpm -qi MariaDB-server
Name : MariaDB-server
Version : 10.5.4
Release : 1.el8
Architecture: x86_64
Install Date: Sun 28 Jun 2020 07:21:20 PM CEST
Group : Applications/Databases
Size : 132807324
License : GPLv2
Signature : DSA/SHA1, Tue 23 Jun 2020 11:03:04 PM CEST, Key ID cbcb082a1bb943db
Source RPM : MariaDB-server-10.5.4-1.el8.src.rpm
Build Date : Tue 23 Jun 2020 06:59:51 PM CEST
Build Host : rhel8-amd64
Relocations : (not relocatable)
Vendor : MariaDB Foundation
URL : http://mariadb.org
....

步骤3:在CentOS 8 | CentOS 7系统中启动MariaDB服务

CentOS 8和CentOS 7均使用Systemd初始化系统。我们可以使用systemctl命令启动服务,如下命令。

sudo systemctl start mariadb

要使服务器重新启动时能够启动服务,请使用以下命令:

$ sudo systemctl enable mariadb
Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service → /usr/lib/systemd/system/mariadb.service.

使用systemctl status命令检查服务状态:

$ systemctl status mariadb
● mariadb.service - MariaDB 10.5.4 database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
Drop-In: /etc/systemd/system/mariadb.service.d

       └─migrated-from-my.cnf-settings.conf

Active: active (running) since Sun 2020-06-28 19:34:56 CEST; 1min 35s ago

 Docs: man:mariadbd(8)
       https://mariadb.com/kb/en/library/systemd/

Main PID: 4328 (mariadbd)
Status: "Taking your SQL requests now..."

Tasks: 9 (limit: 24392)

Memory: 67.7M
CGroup: /system.slice/mariadb.service

       └─4328 /usr/sbin/mariadbd

Jun 28 19:34:56 centos.computingforgeeks.com mariadbd[4328]: 2020-06-28 19:34:56 0 [Note] InnoDB: 10.5.4 started; log sequence number 45041; transaction id 21
Jun 28 19:34:56 centos.computingforgeeks.com mariadbd[4328]: 2020-06-28 19:34:56 0 [Note] Plugin 'FEEDBACK' is disabled.
Jun 28 19:34:56 centos.computingforgeeks.com mariadbd[4328]: 2020-06-28 19:34:56 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
Jun 28 19:34:56 centos.computingforgeeks.com mariadbd[4328]: 2020-06-28 19:34:56 0 [Note] InnoDB: Buffer pool(s) load completed at 200628 19:34:56
Jun 28 19:34:56 centos.computingforgeeks.com mariadbd[4328]: 2020-06-28 19:34:56 0 [Note] Server socket created on IP: '::'.
Jun 28 19:34:56 centos.computingforgeeks.com mariadbd[4328]: 2020-06-28 19:34:56 0 [Note] Reading of all Master_info entries succeeded
Jun 28 19:34:56 centos.computingforgeeks.com mariadbd[4328]: 2020-06-28 19:34:56 0 [Note] Added new Master_info '' to hash table
Jun 28 19:34:56 centos.computingforgeeks.com mariadbd[4328]: 2020-06-28 19:34:56 0 [Note] /usr/sbin/mariadbd: ready for connections.
Jun 28 19:34:56 centos.computingforgeeks.com mariadbd[4328]: Version: '10.5.4-MariaDB' socket: '/var/lib/mysql/mysql.sock' port: 3306 MariaDB Server
Jun 28 19:34:56 centos.computingforgeeks.com systemd[1]: Started MariaDB 10.5.4 database server.
...

如果您需要网络中的其他系统访问数据库服务器,请允许端口3306:

sudo firewall-cmd --add-service=mysql --permanent
sudo firewall-cmd --reload

为了使远程连接正常工作,该服务应侦听IP地址,而不是localhost环回接口。

bind-address=172.21.200.12
bind-address=0.0.0.0

步骤4:在CentOS 8 | CentOS 7系统上保护MariaDB数据库的安全

MariaDB提供了用于强化数据库服务器的脚本。该脚本可提高安全,主要包括:

设置root密码
删除匿名数据库用户
禁止以root用户身份登录远程数据库
删除测试数据库

要启动数据库强化过程,请运行以下命令。

$ sudo mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB

  SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
haven't set the root password yet, you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password or using the unix_socket ensures that nobody
can log into the MariaDB root user without the proper authorisation.

You already have your root account protected, so you can safely answer 'n'.

Switch to unix_socket authentication [Y/n] y
Enabled successfully!
Reloading privilege tables..
... Success!

You already have your root account protected, so you can safely answer 'n'.

Change the root password? [Y/n] y

New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!

By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for

  1. This is intended only for testing, and to make the installation
  2. a bit smoother. You should remove them before moving into a

production environment.

Remove anonymous users? [Y/n] 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? [Y/n] y
... Success!

By default, MariaDB comes with a database named 'test' that anyone can

  1. This is also intended only for testing, and should be removed
  2. moving into a production environment.

Remove test database and access to it? [Y/n] 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? [Y/n] y
... Success!

Cleaning up...

All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

最后以root用户身份(不输入密码)测试登录名:

$ mysql -u root

这时会出现拒绝访问错误:

ERROR 1698 (28000): Access denied for user 'root'@'localhost'

现在以root用户身份尝试并提供密码:

$ mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or g.
Your MariaDB connection id is 24
Server version: 10.5.4-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

MariaDB [(none)]> SELECT VERSION();
VERSION()
10.5.4-MariaDB

1 row in set (0.001 sec)

MariaDB [(none)]> QUIT
Bye

至此,MariaDB 10.5服务现在可以使用了。当然,可能需要的唯一其他设置是根据您的应用程序要求和用例将其调整为最佳性能。本文就不赘述了。

以上安装过程仅供参考,文章来源惠主机www.idccoupon.com ,有任何问题欢迎交流填了。

相关实践学习
每个IT人都想学的“Web应用上云经典架构”实战
本实验从Web应用上云这个最基本的、最普遍的需求出发,帮助IT从业者们通过“阿里云Web应用上云解决方案”,了解一个企业级Web应用上云的常见架构,了解如何构建一个高可用、可扩展的企业级应用架构。
MySQL数据库入门学习
本课程通过最流行的开源数据库MySQL带你了解数据库的世界。 &nbsp; 相关的阿里云产品:云数据库RDS MySQL 版 阿里云关系型数据库RDS(Relational Database Service)是一种稳定可靠、可弹性伸缩的在线数据库服务,提供容灾、备份、恢复、迁移等方面的全套解决方案,彻底解决数据库运维的烦恼。 了解产品详情:&nbsp;https://www.aliyun.com/product/rds/mysql&nbsp;
相关文章
|
5月前
|
关系型数据库 MySQL Linux
CentOS系统安装phpStudy的详细步骤和注意事项
一、安装流程 执行官方安装脚本 通过以下命令直接安装官方集成环境(支持CentOS 7及以上版本): ``` yum install -y wget && wget -O install.sh https://www.hsbang.com/ install.sh && sh install.sh ``` 安装过程包含自动下载组件和配置环境,需等待2-5分钟。
254 4
|
6月前
|
关系型数据库 MySQL Linux
CentOS 7系统下详细安装MySQL 5.7的步骤:包括密码配置、字符集配置、远程连接配置
以上就是在CentOS 7系统下安装MySQL 5.7的详细步骤。希望这个指南能帮助你顺利完成安装。
1464 26
|
7月前
|
存储 Linux 网络安全
如何从CentOS7升级到8?CentOS8最新安装教程
从CentOS 7升级到8只需三步:清理系统、更换软件包及存储库、安装新内核与发布版本。首先确保系统最新并清理冗余包,接着替换基础系统包为CentOS 8版本,最后通过DNF工具完成内核更新与系统同步。整个过程需在终端执行,建议升级前备份VPS快照以防数据丢失。此方法可避免重装系统导致的数据清除问题,实现平滑升级。
955 6
|
Oracle 关系型数据库 MySQL
centos6安装mariadb失败及解决办法
centos6安装mariadb失败及解决办法
468 4
|
Linux 虚拟化 数据安全/隐私保护
部署05-VMwareWorkstation中安装CentOS7 Linux操作系统, VMware部署CentOS系统第一步,下载Linux系统,/不要忘, CentOS -7-x86_64-DVD
部署05-VMwareWorkstation中安装CentOS7 Linux操作系统, VMware部署CentOS系统第一步,下载Linux系统,/不要忘, CentOS -7-x86_64-DVD
|
Unix Linux 开发工具
centos的官网下载和vm16虚拟机安装centos8【保姆级教程图解】
本文详细介绍了如何在官网下载CentOS 8以及在VMware Workstation Pro 16虚拟机上安装CentOS 8的步骤,包括可能出现的问题和解决方案,如vcpu-0错误的处理方法。
centos的官网下载和vm16虚拟机安装centos8【保姆级教程图解】
|
12月前
|
Oracle 关系型数据库 MySQL
CentOS7安装MariaDB成功的实践
CentOS7安装MariaDB成功的实践
313 0
|
网络协议 Linux
CentOS7 yum安装报错“Could not resolve host: mirrorlist.centos.org;"之解决办法(换源)
CentOS7 yum安装报错“Could not resolve host: mirrorlist.centos.org; Name or service not known“之解决办法(换源)
|
Linux vr&ar C语言
Linux怎样更新Centos下Gcc版本支持C17?Centos7快速安装gcc8.3.1 可支持C++17(附gcc相关链接整理)
Linux怎样更新Centos下Gcc版本支持C17?Centos7快速安装gcc8.3.1 可支持C++17(附gcc相关链接整理)
1067 2
|
安全 Linux Anolis
centos停止更新?这篇博客教会你CentOS 7转化系统为阿里龙蜥Anolis OS 7
centos停止更新?这篇博客教会你CentOS 7转化系统为阿里龙蜥Anolis OS 7
1110 0