博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
如何在CentOS 8上安装MariaDB
阅读量:2506 次
发布时间:2019-05-11

本文共 6127 字,大约阅读时间需要 20 分钟。

介绍 (Introduction)

is an open-source database management system, commonly used as an alternative for the MySQL portion of the popular (Linux, Apache, MySQL, PHP/Python/Perl) stack. It is intended to be a drop-in replacement for MySQL.

是一个开源数据库管理系统,通常用作流行的 (Linux,Apache,MySQL,PHP / Python / Perl)堆栈MySQL部分的替代方案。 它旨在替代MySQL。

In this tutorial, we will explain how to install the latest version of MariaDB on a CentOS 8 server. If you’re wondering about MySQL vs. MariaDB, MariaDB is the preferred package and should work seamlessly in place of MySQL. If you specifically need MySQL, see the guide.

在本教程中,我们将说明如何在CentOS 8服务器上安装最新版本的MariaDB。 如果您想了解MySQL与MariaDB,MariaDB是首选软件包,可以代替MySQL无缝运行。 如果您特别需要MySQL,请参阅《 指南。

先决条件 (Prerequisites)

To follow this tutorial, you will need a CentOS 8 server with a non-root sudo-enabled user. You can learn more about how to set up a user with these privileges in the guide.

要学习本教程,您将需要一个CentOS 8服务器与非 sudo -启用用户。 您可以在《 进行指南中了解有关如何使用这些特权设置用户的更多信息。

第1步-安装MariaDB (Step 1 — Installing MariaDB)

First, use dnf to install the MariaDB package:

首先,使用dnf安装MariaDB软件包:

  • sudo dnf install mariadb-server

    须藤dnf安装mariadb服务器

You will be asked to confirm the action. Press y then ENTER to proceed.

系统将要求您确认操作。 按y然后按ENTER以继续。

Once the installation is complete, start the service with systemctl:

安装完成后,使用systemctl启动服务:

  • sudo systemctl start mariadb

    sudo systemctl启动mariadb

Then check the status of the service:

然后检查服务状态:

  • sudo systemctl status mariadb

    sudo systemctl状态mariadb
Output   
● mariadb.service - MariaDB 10.3 database server Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled) Active: active (running) since Fri 2020-04-03 17:32:46 UTC; 52min ago Docs: man:mysqld(8) https://mariadb.com/kb/en/library/systemd/ Main PID: 4567 (mysqld) Status: "Taking your SQL requests now..." Tasks: 30 (limit: 5059) Memory: 77.1M CGroup: /system.slice/mariadb.service └─4567 /usr/libexec/mysqld --basedir=/usr. . .Apr 03 17:32:46 centos8-mariadb systemd[1]: Started MariaDB 10.3 database server.

If MariaDB has successfully started, the output should show active (running) and the final line should look something like:

如果MariaDB已成功启动,则输出应显示为active (running) ,最后一行应类似于:

Output   
Apr 03 17:32:46 centos8-mariadb systemd[1]: Started MariaDB 10.3 database server..

Next, let’s take a moment to ensure that MariaDB starts at boot, using the systemctl enable command:

接下来,让我们花点时间使用systemctl enable命令确保MariaDB在启动时启动:

  • sudo systemctl enable mariadb

    sudo systemctl启用mariadb
Output   
Created symlink /etc/systemd/system/mysql.service → /usr/lib/systemd/system/mariadb.service.Created symlink /etc/systemd/system/mysqld.service → /usr/lib/systemd/system/mariadb.service.Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service → /usr/lib/systemd/system/mariadb.service.

We now have MariaDB running and configured to run at startup. Next, we’ll turn our attention to securing our installation.

现在,我们运行了M​​ariaDB,并将其配置为在启动时运行。 接下来,我们将注意力转移到确保安装安全上。

第2步-保护MariaDB服务器 (Step 2 — Securing the MariaDB Server)

MariaDB includes a security script to change some of the less secure default options for things like remote root logins and sample users. Use this command to run the security script:

MariaDB包含一个安全脚本,用于更改一些不太安全的默认选项,例如远程root登录和样本用户。 使用此命令运行安全脚本:

  • sudo mysql_secure_installation

    须藤mysql_secure_installation

The script provides a detailed explanation for every step. The first step asks for the root password, which hasn’t been set so we’ll press ENTER as it recommends. Next, we’ll be prompted to set that root password. Keep in mind that this is for the root database user, not the root user for your CentOS server itself.

该脚本为每个步骤提供了详细的说明。 第一步要求输入root密码(尚未设置),因此我们将按建议的方式按ENTER 。 接下来,将提示我们设置该根密码。 请记住,这是针对root 数据库用户 ,而不是CentOS服务器本身的root用户。

Type Y then ENTER to enter a password for the root database user, then follow the prompts.

键入Y然后按ENTER输入数据库用户的密码,然后按照提示进行操作。

After updating the password, we will accept all the security suggestions that follow by pressing y and then ENTER. This will remove anonymous users, disallow remote root login, remove the test database, and reload the privilege tables.

更新密码后,我们将接受所有安全建议,方法是依次按yENTER 。 这将删除匿名用户,禁止远程root登录,删除测试数据库并重新加载特权表。

Now that we’ve secured the installation, we’ll verify it’s working by connecting to the database.

现在,我们已经确保了安装的安全,我们将通过连接到数据库来验证其是否正常运行。

第3步-测试安装 (Step 3 — Testing the Installation)

We can verify our installation and get information about it by connecting with the mysqladmin tool, a client that lets you run administrative commands. Use the following command to connect to MariaDB as root (-u root), prompt for a password (-p), and return the version.

我们可以通过连接mysqladmin工具来验证我们的安装并获取有关安装的信息,该工具允许您运行管理命令。 使用以下命令以root用户身份( -u root )连接到MariaDB,提示输入密码( -p ),然后返回版本。

  • mysqladmin -u root -p version

    mysqladmin -u root -p版本

You should see output similar to this:

您应该看到类似于以下的输出:

Output   
mysqladmin Ver 9.1 Distrib 10.3.17-MariaDB, for Linux on x86_64Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.Server version 10.3.17-MariaDBProtocol version 10Connection Localhost via UNIX socketUNIX socket /var/lib/mysql/mysql.sockUptime: 6 min 5 secThreads: 7 Questions: 16 Slow queries: 0 Opens: 17 Flush tables: 1 Open tables: 11 Queries per second avg: 0.043

This indicates the installation has been successful.

这表明安装已成功。

结论 (Conclusion)

In this guide you installed MariaDB to act as an SQL server. During the installation process you also secured the server. Optionally, you also created a separate password-authenticated administrative user.

在本指南中,您安装了MariaDB以充当SQL Server。 在安装过程中,您还保护了服务器。 (可选)您还创建了一个单独的经过密码验证的管理用户。

Now that you have a running and secure MariaDB server, here some examples of next steps that you can take to work with the server:

既然您已经有一个运行中且安全的MariaDB服务器,那么下面是您可以使用该服务器的一些后续步骤示例:

  • You may want to

    您可能要

  • You could incorporate MariaDB into a larger software stack, such as the LAMP stack:

    您可以将MariaDB合并到更大的软件堆栈中,例如LAMP堆栈:

  • You may need to to allow for external database traffic

    您可能需要以允许外部数据库流量

翻译自:

转载地址:http://pvhgb.baihongyu.com/

你可能感兴趣的文章
进程和线程概念及原理
查看>>
Dubbo超时重试机制带来的数据重复问题
查看>>
注解配置里的几个注解
查看>>
使ie678支持css3伪类选择器的插件
查看>>
题解报告:hdu 1212 Big Number(大数取模+同余定理)
查看>>
POJ 3624 Charm Bracelet
查看>>
ZOJ 2314 Reactor Cooling
查看>>
关于做事的一点想法
查看>>
程序在本地能启动而预发布不能启动
查看>>
Lucene、ES好文章
查看>>
有关定时器setTimeout()、setInterval()详解
查看>>
刷题总结——次小生成树(bzoj1977 最小生成树+倍增)
查看>>
html5-2 html实体和颜色有哪些
查看>>
饺紫猫配色教程
查看>>
第三百六十九节,Python分布式爬虫打造搜索引擎Scrapy精讲—elasticsearch(搜索引擎)用Django实现搜索功能...
查看>>
第八十节,CSS3边框图片效果
查看>>
第一百九十五节,jQuery EasyUI,Resizable(调整大小)组件
查看>>
Gym 101128F Landscaping(网络流)题解
查看>>
使用Expression进行查询拼接
查看>>
父页面获得子页面的值
查看>>