在 CentOS 7 上安装 MariaDB 10.3 服务器

MariaDB 是 MySQL 关系型数据库管理系统的著名分支。

就像MySQL一样,MariaDB 在 GNU GPL 许可下也是免费和开源的。

在本文中,我们将在 CentOS 7 服务器上安装 MariaDB 10.3.

更多: zhilu jiaocheng

在 CentOS 7 上安装 MariaDB 10.3

使用 ssh 连接到 mariadb-01.onitroad.com。

MariaDB 软件包可通过标准 yum 存储库获得。
但是,我们正在安装 MariaDB 10.3.12(撰写本文时的最新稳定版本),因此,我们必须从 MariaDB Downloads 下载其 tar包,或者我们可以添加 MariaDB yum 存储库。

我们正在安装 MariaDB yum 存储库,如下所示。

[root@mariadb-01 ~]# vi /etc/yum.repos.d/mariadb.repo

其中添加以下指令。

[mariadb]
name=MariaDB
baseurl=http://yum.mariadb.org/10.3/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
enabled=1

在使用 MariaDB yum 存储库之前,我们必须导入 GPG 公钥来验证此存储库中包的数字签名。

虽然,没有必要手动导入 GPG 公钥。
当我们第一次从 MariaDB yum 存储库安装包时,yum 会自动安装 GPG 公钥。

在这里,为了演示,我们手动导入 GPG 公钥。

[root@mariadb-01 ~]# rpm --import https://yum.mariadb.org/RPM-GPG-KEY-MariaDB

使用以下命令构建 yum 缓存。

[root@mariadb-01 ~]# yum makecache fast

使用 yum 命令安装 MariaDB 服务器。

[root@mariadb-01 ~]# yum install -y mariadb-server

启动并启用 MariaDB 服务。

[root@mariadb-01 ~]# systemctl start mariadb
[root@mariadb-01 ~]# systemctl enable mariadb

配置 MariaDB 数据库实例。

[root@mariadb-01 ~]# 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!

登录到 MariaDB 数据库服务器。

[root@mariadb-01 ~]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 16
Server version: 10.3.12-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)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.001 sec)

MariaDB 10.3 服务器已安装在 CentOS 7 上。

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