如何在Fedora 32/31/30/29上安装MariaDB 10.5

时间:2020-02-23 14:40:55  来源:igfitidea点击:

在本教程中,我们将介绍在Fedora 32/31/30/29上的MariaDB 10.5安装。 MariaDB是MySQL的直接替代品。它是一个健壮,有弹性,可扩展且可靠的RDBMS,具有以前仅在昂贵的专有数据库中可用的功能。 MariaDB数据库服务器以通用公共许可证版本2作为免费和开源软件发布。

添加MariaDB Yum存储库

我们需要添加YUM存储库以在Fedora 32/31/30/29 Linux上安装MariaDB 10.5.

将存储库添加到Fedora 32/31/30。

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

将存储库添加到Fedora 29.

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

完成后导入存储库GPG密钥。

sudo rpm --import https://yum.mariadb.org/RPM-GPG-KEY-MariaDB

在Fedora 32/31/30/29上安装MariaDB 10.5

使用以下命令在Fedora系统上安装MariaDB 10.5.

sudo dnf install MariaDB-server MariaDB-client

同意开始安装。

Transaction Summary
================================================================================================================================================================
Install  52 Packages

Total download size: 66 M
Installed size: 300 M
Is this ok [y/N]: y

安装MariaDB服务器后,启动服务并将其设置为在启动时启动。

sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service

安全安装MariaDB

安装后,MariaDB服务器未经过加固,无需身份验证即可轻松访问。

通过运行以下脚本来保护数据库。

$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: <ENTER NEW PASSWORD>
Re-enter new password: <CONFIRM 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!

确保我们:设置数据库root用户密码删除匿名用户禁止root用户远程登录删除测试数据库并对其进行访问

完成后,使用没有密码的root用户测试访问。

$mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

如图所示,我们需要进行身份验证才能以root用户身份访问数据库控制台。

$mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 19
Server version: 10.3.14-MariaDB MariaDB Server
Copyright (c) 2000, 2016, 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.3.14-MariaDB |
 +-----------------+
 1 row in set (0.000 sec)

对于需要更简单方法来管理MariaDB数据库服务器的开发人员,请查看有关在Fedora上安装和配置phpMyAdmin的教程。