如何升级 MariaDB 在 Linux (阿尔玛Linux)

MariaDB 是著名的开源软件 关系型数据库。 参与其中的开发人员相同 MySQL 已创建 MariaDB 并承诺保持开源。 它包含在大多数 Cloud-服务 大多数情况下是默认值 Linux 变种。 它基于性能、稳定性和开放性的原则。 除此之外 MariaDB 基金会、捐赠 保证贡献因其技术质量而被接受。 您的持续进一步发展 MariaDB 保持版本最新可确保您利用数据库平台的最佳功能。

获取 VPS 托管

很多的 每一项都有新功能和改进 MariaDB 发布。 要接收重要的安全更新并避免与其他应用程序的兼容性问题,您必须升级 MariaDB 到较新的受支持版本。 如果你留下来 MariaDB 保持最新状态可为您带来许多好处,例如改进的性能、增强的安全性、新功能等等。

之前的先决条件 MariaDB 升级

  • 操作系统及版本: 操作系统必须是 阿尔玛Linux操作系统8 对于本教程。
  • 数据库及版本: A MariaDB 执行 这不是最新的。
  • Linux 管理员权限: 要登录AlmaLinux 8系统,请使用 sudo 以 root 身份运行命令 或作为 具有管理员权限的用户

更新 MariaDB 在AlmaLinux上

步骤#1:检查 MariaDB 和AlmaLinux版本

您可以检查当前版本 MariaDB 和 AlmaLinux,运行以下命令:

  • ~]# mysql -V
  • ~]# cat /etc/redhat-release

这是输出:

[root@nouf ~]# mysql -V
mysql  Ver 15.1 Distrib 10.5.21-MariaDB, for Linux (x86_64) using readline 5.1
[root@nouf ~]# cat /etc/redhat-release 
AlmaLinux release 8.8 (Sapphire Caracal)

步骤#2:备份数据库

在执行之前 MariaDB 升级时,创建现有数据库和数据库配置文件的备份或转储至关重要。

要备份数据库,请使用以下命令:

  • ~]# mysqldump –all-databases > /tmp/all-database-backup.sql

要将数据库目录复制到另一个文件夹,请使用以下命令:

  • ~]# cp -a /var/lib/mysql /var/lib/mysql_oldbackup

要备份配置文件,请使用以下命令:

  • ~]# cp -a /etc/my.cnf /etc/my.cnf_oldbackup

请注意,内容 /etc/my.cnf.d/ 如果该文件存在,则还必须对其进行备份。 Liquid Web Core 管理的 AlmaLinux 8 服务器 包含该文件。

步骤#3:卸载当前的 MariaDB 存储库

安装最新版本之前,请先卸载旧版本 MariaDB 存储库。 您可以使用以下命令来停止它 MariaDB 服务:

  • ~]# systemctl 停止 mariadb

确认MariaDB要确定使用以下命令的当前状态:

  • ~]# systemctl 状态 mariadb

要重命名或移动当前存储库文件,请使用以下命令:

  • ~]# mv /etc/yum.repos.d/mariadb.repo /etc/yum.repos.d/mariadb.repo_oldbackup

步骤#4:添加新的 MariaDB 存储库(“repo”)

在创建新的之前 MariaDB 在存储库中,您需要更新所有包。 您可以使用以下命令更新所有包:

  • ~]# sudo dnf更新-y

您现在可以为最新版本创建新的存储库文件 MariaDB 执行:

  • ~]# vi /etc/yum.repos.d/mariadb.repo

然后添加以下详细信息 /etc/yum.repos.d/mariadb.repo 归档并保存文件:

[mariadb]
name = MariaDB
baseurl = https://yum.mariadb.org/10.5/rhel8-amd64
module_hotfixes=1
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

步骤#5:卸载旧的 MariaDB 执行

您可以卸载旧版本 MariaDB 使用以下命令:

  • ~]# sudo 删除 dnf MariaDB-服务器-y

要清理服务器上的存储库缓存,请使用以下命令:

  • ~]# sudo dnf清理一切

步骤#6:安装最新版本 MariaDB 执行

现在您已准备好升级 MariaDB。 安装最新版本 MariaDB 版本使用以下命令:

  • ~]# sudo 安装dnf MariaDB-服务器-y

这是输出:

[root@nouf ~]# sudo dnf install MariaDB-server -y
AlmaLinux 8 - BaseOS                                                                                                                     6.0 MB/s | 4.0 MB     00:00    
AlmaLinux 8 - AppStream                                                                                                                   16 MB/s |  11 MB     00:00    
AlmaLinux 8 - Extras                                                                                                                      32 kB/s |  18 kB     00:00    
MariaDB                                                                                                                                  1.0 MB/s | 620 kB     00:00    
Dependencies resolved.
=========================================================================================================================================================================
 Package                                          Architecture                      Version                                   Repository                            Size
=========================================================================================================================================================================
Installing:
 MariaDB-server                                   x86_64                            10.10.5-1.el8                             mariadb                               27 M

—-
—-

Installed:
  MariaDB-server-10.10.5-1.el8.x86_64  boost-program-options-1.66.0-13.el8.x86_64  galera-4-26.4.14-1.el8.x86_64  libpmem-1.6.1-1.el8.x86_64  lsof-4.93.2-1.el8.x86_64 
  socat-1.7.4.1-1.el8.x86_64          

Complete!

最常见的安装方式 MariaDB 套餐作为总套餐的一部分 MariaDB 要升级,请使用以下命令:

  • ~]# sudo 安装 dnf Galera-4 MariaDB-客户 MariaDB-分为 MariaDB-备份 MariaDB-一起-y

步骤#7:开始 MariaDB

要开始这个 MariaDB 服务使用以下命令:

  • ~]# sudo systemctl 启动 mariadb

步骤#8:设置 MariaDB 在启动时启动

调整 MariaDB 要在引导时启动,请使用以下命令:

  • ~]# sudo systemctl 启用 mariadb

这是输出:

[root@nouf ~]# sudo systemctl enable mariadb 
Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service → /usr/lib/systemd/system/mariadb.service.

步骤#9:升级 MariaDB

要升级 MariaDB,请使用以下命令:

  • ~]# mysql_upgrade

这是输出:

[root@nouf ~]# mysql_upgrade 
Major version upgrade detected from 10.5.21-MariaDB to 10.10.5-MariaDB. Check required!
Phase 1/7: Checking and upgrading mysql database
Processing databases
mysql
mysql.column_stats                                 OK
mysql.columns_priv                                 OK
mysql.db                                           OK
mysql.event                                        OK
mysql.func                                         OK
mysql.gtid_slave_pos                               OK
mysql.help_category                                OK
mysql.help_keyword                                 OK
mysql.help_relation                                OK
mysql.help_topic                                   OK
mysql.host                                         OK
mysql.index_stats                                  OK
mysql.innodb_index_stats                           OK
mysql.innodb_table_stats                           OK
mysql.plugin                                       OK
mysql.proc                                         OK
mysql.procs_priv                                   OK
mysql.proxies_priv                                 OK
mysql.roles_mapping                                OK
mysql.servers                                      OK
mysql.table_stats                                  OK
mysql.tables_priv                                  OK
mysql.time_zone                                    OK
mysql.time_zone_leap_second                        OK
mysql.time_zone_name                               OK
mysql.time_zone_transition                         OK
mysql.time_zone_transition_type                    OK
mysql.transaction_registry                         OK
mysql.user                                         OK
Phase 2/7: Installing used storage engines... Skipped
Phase 3/7: Fixing views
Phase 4/7: Running 'mysql_fix_privilege_tables'
Phase 5/7: Fixing table and database names
Phase 6/7: Checking and upgrading tables
Processing databases
information_schema
performance_schema
Phase 7/7: Running 'FLUSH PRIVILEGES'
OK

第10步:检查电源 MariaDB 执行

使用以下命令检查并验证当前安装的版本 MariaDB 执行:

  • ~]# mysql -V

这是输出:

[root@nouf ~]# mysql -V
mysql  Ver 15.1 Distrib 10.10.5-MariaDB, for Linux (x86_64) using readline 5.1
[root@nouf ~]# 

恭喜本次活动圆满结束 MariaDB 更新!

确保那些 MariaDB 数据库

最新版本 MariaDB 在AlmaLinux 8上设置。 现在你可以 确保 MariaDB 数据库 使用以下命令:

  • ~]# sudo mysql_安全_安装

这是输出:

[root@nouf ~]# 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
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

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

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

Set 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
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? [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
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? [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!

如果你想切换 MySQL 前往 MariaDB 了解更多信息 之间的主要区别 MySQL 和 MariaDB 在我们的 知识库博客在线资源。 一旦你运行 MariaDB,你需要执行 MariaDB 不时升级以利用更新的功能。

文凭

您现在应该了解如何升级 MariaDB 在AlmaLinux上。 要创建备份,请卸载以前的版本并备份 MariaDB 升级后也被覆盖。 MariaDB 是一个很好的替代品 MySQL 用于数据库托管。

显示所有产品

流体网 可以帮助你升级 MariaDB 在托管上 Linux 服务器。 我们的 专用服务器 只是几种选择之一。 如果您在配置网络托管设置和服务器方面需要进一步帮助,请随时与我们联系。

与我们聊天