如何在Fedora 37上安装MySQL

Linux命令 Edge插件网 2年前 (2023-03-11) 496次浏览 已收录 0个评论

MySQL是一种流行且广泛使用的开源关系数据库管理系统(RDBMS),许多基于Web的应用程序使用它来存储和管理数据。其强大的功能集和灵活性使其成为从小型项目到企业级应用程序的各种不同用例的理想选择。如何在Fedora 37上安装MySQL

在 Fedora 37 上安装 MySQL

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

<span class="pln">sudo dnf upgrade
sudo dnf update</span>

第 2 步。在 Fedora 37 上安装 MySQL。

默认情况下,MySQL 软件包不在 Fedora 37 的默认存储库中。现在运行以下命令将 MySQL 存储库添加到您的 Fedora 系统中:

<span class="pln">sudo dnf install https</span><span class="pun">:</span><span class="com">//dev.mysql.com/get/mysql80-community-release-fc37-1.noarch.rpm</span>

添加 MySQL Yum 仓库后,您可以通过运行以下命令在 Fedora 37 系统上安装 MySQL:

<span class="pln">sudo dnf install mysql</span><span class="pun">-</span><span class="pln">community</span><span class="pun">-</span><span class="pln">server</span>

安装完成后,通过运行以下命令启动 MySQL 服务:

<span class="pln">sudo systemctl start mysqld
sudo systemctl enable mysqld</span>

要验证是否已安装 MySQL,请运行以下命令:

<span class="pln">mysql </span><span class="pun">--</span><span class="pln">version</span>

第 3 步。保护 MySQL 安装。

MySQL附带了一个脚本,可以帮助您保护安装。若要运行此脚本,请键入以下命令:

<span class="pln">sudo mysql_secure_installation</span>

此命令将启动MySQL安全安装向导,该向导将指导您完成保护MySQL服务器的过程。系统将提示您设置 root 密码、删除匿名用户、禁用远程 root 登录以及删除测试数据库。按照提示完成设置。

输出:

<span class="typ">Securing</span><span class="pln"> the </span><span class="typ">MySQL</span><span class="pln"> server deployment</span><span class="pun">.</span>

<span class="typ">Enter</span><span class="pln"> password </span><span class="kwd">for</span><span class="pln"> user root</span><span class="pun">:</span> 

<span class="typ">The</span><span class="pln"> existing password </span><span class="kwd">for</span><span class="pln"> the user account root has expired</span><span class="pun">.</span> <span class="typ">Please</span> <span class="kwd">set</span><span class="pln"> a </span><span class="kwd">new</span><span class="pln"> password</span><span class="pun">.</span>

<span class="typ">New</span><span class="pln"> password</span><span class="pun">:</span> 

<span class="typ">Re</span><span class="pun">-</span><span class="pln">enter </span><span class="kwd">new</span><span class="pln"> password</span><span class="pun">:</span> 
<span class="typ">The</span> <span class="str">'validate_password'</span><span class="pln"> component </span><span class="kwd">is</span><span class="pln"> installed on the server</span><span class="pun">.</span>
<span class="typ">The</span><span class="pln"> subsequent steps will run </span><span class="kwd">with</span><span class="pln"> the existing configuration
</span><span class="kwd">of</span><span class="pln"> the component</span><span class="pun">.</span>
<span class="typ">Using</span><span class="pln"> existing password </span><span class="kwd">for</span><span class="pln"> root</span><span class="pun">.</span>

<span class="typ">Estimated</span><span class="pln"> strength </span><span class="kwd">of</span><span class="pln"> the password</span><span class="pun">:</span> <span class="lit">100</span> 
<span class="typ">Change</span><span class="pln"> the password </span><span class="kwd">for</span><span class="pln"> root </span><span class="pun">?</span> <span class="pun">((</span><span class="typ">Press</span><span class="pln"> y</span><span class="pun">|</span><span class="pln">Y </span><span class="kwd">for</span> <span class="typ">Yes</span><span class="pun">,</span><span class="pln"> any other key </span><span class="kwd">for</span> <span class="typ">No</span><span class="pun">)</span> <span class="pun">:</span><span class="pln"> y

</span><span class="typ">New</span><span class="pln"> password</span><span class="pun">:</span> 

<span class="typ">Re</span><span class="pun">-</span><span class="pln">enter </span><span class="kwd">new</span><span class="pln"> password</span><span class="pun">:</span> 

<span class="typ">Estimated</span><span class="pln"> strength </span><span class="kwd">of</span><span class="pln"> the password</span><span class="pun">:</span> <span class="lit">100</span> 
<span class="typ">Do</span><span class="pln"> you wish to </span><span class="kwd">continue</span> <span class="kwd">with</span><span class="pln"> the password provided</span><span class="pun">?(</span><span class="typ">Press</span><span class="pln"> y</span><span class="pun">|</span><span class="pln">Y </span><span class="kwd">for</span> <span class="typ">Yes</span><span class="pun">,</span><span class="pln"> any other key </span><span class="kwd">for</span> <span class="typ">No</span><span class="pun">)</span> <span class="pun">:</span><span class="pln"> y
</span><span class="typ">By</span> <span class="kwd">default</span><span class="pun">,</span><span class="pln"> a </span><span class="typ">MySQL</span><span class="pln"> installation has an anonymous user</span><span class="pun">,</span><span class="pln">
allowing anyone to log </span><span class="kwd">into</span> <span class="typ">MySQL</span><span class="pln"> without having to have
a user account created </span><span class="kwd">for</span><span class="pln"> them</span><span class="pun">.</span> <span class="typ">This</span> <span class="kwd">is</span><span class="pln"> intended only </span><span class="kwd">for</span><span class="pln">
testing</span><span class="pun">,</span> <span class="kwd">and</span><span class="pln"> to make the installation go a bit smoother</span><span class="pun">.</span>
<span class="typ">You</span><span class="pln"> should </span><span class="kwd">remove</span><span class="pln"> them before moving </span><span class="kwd">into</span><span class="pln"> a production
environment</span><span class="pun">.</span>

<span class="typ">Remove</span><span class="pln"> anonymous users</span><span class="pun">?</span> <span class="pun">(</span><span class="typ">Press</span><span class="pln"> y</span><span class="pun">|</span><span class="pln">Y </span><span class="kwd">for</span> <span class="typ">Yes</span><span class="pun">,</span><span class="pln"> any other key </span><span class="kwd">for</span> <span class="typ">No</span><span class="pun">)</span> <span class="pun">:</span><span class="pln"> y
</span><span class="typ">Success</span><span class="pun">.</span>

<span class="typ">Normally</span><span class="pun">,</span><span class="pln"> root should only be allowed to connect </span><span class="kwd">from</span>
<span class="str">'localhost'</span><span class="pun">.</span> <span class="typ">This</span><span class="pln"> ensures that someone cannot guess at
the root password </span><span class="kwd">from</span><span class="pln"> the network</span><span class="pun">.</span>

<span class="typ">Disallow</span><span class="pln"> root login remotely</span><span class="pun">?</span> <span class="pun">(</span><span class="typ">Press</span><span class="pln"> y</span><span class="pun">|</span><span class="pln">Y </span><span class="kwd">for</span> <span class="typ">Yes</span><span class="pun">,</span><span class="pln"> any other key </span><span class="kwd">for</span> <span class="typ">No</span><span class="pun">)</span> <span class="pun">:</span><span class="pln"> y
</span><span class="typ">Success</span><span class="pun">.</span>

<span class="typ">By</span> <span class="kwd">default</span><span class="pun">,</span> <span class="typ">MySQL</span><span class="pln"> comes </span><span class="kwd">with</span><span class="pln"> a database named </span><span class="str">'test'</span><span class="pln"> that
anyone can access</span><span class="pun">.</span> <span class="typ">This</span> <span class="kwd">is</span><span class="pln"> also intended only </span><span class="kwd">for</span><span class="pln"> testing</span><span class="pun">,</span>
<span class="kwd">and</span><span class="pln"> should be removed before moving </span><span class="kwd">into</span><span class="pln"> a production
environment</span><span class="pun">.</span>

<span class="typ">Remove</span><span class="pln"> test database </span><span class="kwd">and</span><span class="pln"> access to it</span><span class="pun">?</span> <span class="pun">(</span><span class="typ">Press</span><span class="pln"> y</span><span class="pun">|</span><span class="pln">Y </span><span class="kwd">for</span> <span class="typ">Yes</span><span class="pun">,</span><span class="pln"> any other key </span><span class="kwd">for</span> <span class="typ">No</span><span class="pun">)</span> <span class="pun">:</span><span class="pln"> y
 </span><span class="pun">-</span> <span class="typ">Dropping</span><span class="pln"> test database</span><span class="pun">...</span>
<span class="typ">Success</span><span class="pun">.</span>

 <span class="pun">-</span> <span class="typ">Removing</span><span class="pln"> privileges on test database</span><span class="pun">...</span>
<span class="typ">Success</span><span class="pun">.</span>

<span class="typ">Reloading</span><span class="pln"> the privilege tables will </span><span class="kwd">ensure</span><span class="pln"> that all changes
made so far will take effect immediately</span><span class="pun">.</span>

<span class="typ">Reload</span><span class="pln"> privilege tables now</span><span class="pun">?</span> <span class="pun">(</span><span class="typ">Press</span><span class="pln"> y</span><span class="pun">|</span><span class="pln">Y </span><span class="kwd">for</span> <span class="typ">Yes</span><span class="pun">,</span><span class="pln"> any other key </span><span class="kwd">for</span> <span class="typ">No</span><span class="pun">)</span> <span class="pun">:</span><span class="pln"> y
</span><span class="typ">Success</span><span class="pun">.</span>

<span class="typ">All</span> <span class="kwd">done</span><span class="pun">!</span>

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


Edge插件网 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:如何在Fedora 37上安装MySQL
喜欢 (0)
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址