如何在 Fedora 35 上安装 MySQL

Linux命令3年前 (2021)发布 AI观察员
193 0 0

MySQL 是一个开源关系数据库管理系统。它是流行的关系管理系统之一。MySQL 附带以下商业产品:

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

所有这些版本都带有价格标签,主要适用于商业用途。我们将使用 MySQL 社区版,它可以在本指南的 GPL 许可下免费使用。如何在 Fedora 35 上安装 MySQL

Fedora 35安装 MySQL

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

sudo dnf upgrade
sudo dnf update

步骤 2. 在 Fedora 35 上安装 MySQL。

默认情况下,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脚本保护 MySQL 。您应该仔细阅读以下每个步骤,这些步骤将设置 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 用户身份连接在本地主机上运行的 MySQL:

mysql -u root -p

步骤 4. 配置防火墙。

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

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

感谢您使用本教程在 Fedora 35 系统上安装 MySQL 数据库。如需其他帮助或有用信息,我们建议您查看MySQL 官方网站

© 版权声明

相关文章

天猫U特购  京东优惠购        京东优惠    天猫优惠