如何安装 MySQL Fedora 35

[ad_1]

在本教程中,我们将向您展示如何在 Fedora 35. 对于那些不知道的人,MySQL 是一个开源的关系数据库管理系统。 它是流行的关系管理系统之一。 MySQL 附带以下商业产品:

  • MySQL 标准版。
  • MySQL 企业版。
  • MySQL 集群运营商级版本。

所有这些版本都带有价格标签,主要适用于商业用途。 我们将使用 MySQL 社区版,该版本可在本指南的 GPL 许可下免费使用。

本文假设您至少具备 Linux 的基本知识,知道如何使用 shell,最重要的是,您将网站托管在自己的 VPS 上。 安装非常简单,假设您在 root 帐户下运行,如果不是,您可能需要添加 ‘sudo‘ 到命令以获取 root 权限。 我将向您展示如何在一台服务器上逐步安装 MySQL 服务器 Fedora 35.

安装 MySQL Fedora 35

步骤 1. 在继续之前,请更新您的 Fedora 操作系统以确保所有现有软件包都是最新的。 使用此命令更新服务器包:

sudo dnf upgrade
sudo dnf update

步骤 2. 安装 MySQL Fedora 35.

默认情况下,MySQL 在 Fedora 35 个基础存储库。 然后我们可以使用以下命令安装 MySQL 服务器:

sudo dnf install community-mysql-server

安装完成后我们需要启动MySQL服务器才能开始运行。 我们使用以下命令执行此操作:

sudo systemctl start mysqld
sudo systemctl enable mysqld
sudo systemctl status mysqld

让我们使用以下命令检查 MySQL 版本:

mysql -V

步骤 3. 保护 MySQL 安装。

默认情况下,MySQL 未加固。 您可以使用 mysql_secure_installation 脚本。 您应该仔细阅读下面的每个步骤,这些步骤将设置 root 密码、删除匿名用户、禁止远程 root 登录、删除测试数据库和访问安全 MySQL:

mysql_secure_installation

输出:

Securing the MySQL server deployment.

Enter password for user root: 

The existing password for the user account root has expired. Please set a new password.

New password: 

Re-enter new password: 
The 'validate_password' component is installed on the server.
The subsequent steps will run with the existing configuration
of the component.
Using existing password for root.

Estimated strength of the password: 100 
Change the password for root ? ((Press y|Y for Yes, any other key for No) : y

New password: 

Re-enter new password: 

Estimated strength of the password: 100 
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL 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? (Press y|Y for Yes, any other key for No) : 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? (Press y|Y for Yes, any other key for No) : y
Success.

By default, MySQL 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? (Press y|Y for Yes, any other key for No) : 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? (Press y|Y for Yes, any other key for No) : y
Success.

All done!

全做完了。 您现在可以使用命令行连接到 MySQL 服务器。 以下命令将以 root 用户身份连接在 localhost 上运行的 MySQL:

mysql -u root -p

步骤 4. 配置防火墙。

现在我们允许远程连接,在防火墙上允许端口 3306:

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

恭喜! 您已成功安装 MySQL。 感谢您使用本教程在您的计算机上安装 MySQL 数据库 Fedora 35系统。 如需更多帮助或有用信息,我们建议您查看 MySQL 官方网站.

[ad_2]

Related Posts