当前位置: 首页 > news >正文

MySQL 的mysql_secure_installation安全脚本执行过程介绍

1.设置 MySQL root 用户密码。
2.删除匿名用户。
3.禁止 root 用户远程登录。
4.删除测试数据库。
5.重新加载权限表。
以下是执行 mysql_secure_installation 的详细步骤:

步骤 1:启动 mysql_secure_installation 脚本

打开终端并执行以下命令:
sudo mysql_secure_installation

步骤 2:输入当前的 MySQL root 密码

如果这是第一次设置,MySQL root 用户没有密码,你可以直接按 Enter 键。否则,输入当前的 root 密码。

步骤 3:设置新的 root 密码

你会被询问是否要设置新的 root 密码。如果当前没有设置 root 密码,建议设置一个强密码。输入 Y 并按 Enter,然后按照提示设置密码。

步骤 4:删除匿名用户

删除匿名用户账户,防止未授权用户登录 MySQL。输入 Y 并按 Enter。

5:禁止 root 用户远程登录

为了提高安全性,建议禁止 root 用户远程登录。输入 Y 并按 Enter。

步骤 6:删除测试数据库

删除默认安装的测试数据库,它可以被任何用户访问。输入 Y 并按 Enter。

步骤 7:重新加载权限表

最后,重新加载权限表,以确保所有更改生效。输入 Y 并按 Enter。

完整示例

以下是一个完整的示例输出:
Securing the MySQL server deployment.
Enter password for user root: (输入当前的 root 密码或直接按 Enter 如果没有密码)
The existing password for the user account root has expired. Please set a new password.
New password: (输入新的 root 密码)
Re-enter new password: (重新输入新的 root 密码)

VALIDATE PASSWORD PLUGIN can be used to test passwords and improve security.
It checks the strength of password and allows the users to set only those passwords which are secure enough.

Would you like to setup VALIDATE PASSWORD plugin

Press y|Y for Yes, any other key for No: Y (根据需要选择是否启用密码验证插件)
Please set the password validation policy:

LOW Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary file

Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 1 (选择密码验证策略)
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) : N (如果刚刚设置了密码,这里选择 N)
… skipping.

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 (禁止 root 用户远程登录)
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_secure_installation 并提高了 MySQL 服务器的安全性。

http://www.jsqmd.com/news/510367/

相关文章:

  • 颠覆传统分辨率限制:3个让窗口控制效率提升10倍的SRWE实战技巧
  • PulsDio:嵌入式高可靠脉冲检测与边沿事件处理库
  • Unreal Engine集成ONLYOFFICE Docs:游戏开发文档协作方案
  • oapi-codegen容灾恢复:如何生成数据恢复流程代码的完整指南
  • 如何快速构建AI对话搜索引擎:基于search_with_lepton的完整指南
  • 比迪丽LoRA模型Python入门指南:从零编写你的第一个生成脚本
  • Qwen3-ASR-0.6B真实效果:Zoom会议录音→发言人分离+文字转录
  • 黑丝空姐-造相Z-Turbo技术解析:LSTM在序列化图像生成中的应用探秘
  • Pixel Dimension Fissioner生产环境:灰度发布新裂变模型的A/B测试指标埋点方案
  • 2026年知名的别墅设计品牌推荐:大兴私宅别墅设计/别墅设计预算管控专业推荐公司 - 品牌宣传支持者
  • IndexTTS 2.0问题解决指南:常见错误排查与优化设置,让生成更顺畅
  • System.CommandLine性能优化:终极性能调优指南
  • Phi-3 Forest Laboratory本地化部署指南:应对GitHub访问限制的备选方案
  • 2026年热门的叠螺污泥脱水机-351公司推荐:叠螺污泥脱水机-301/叠螺污泥脱水机-404工厂直供哪家专业 - 品牌宣传支持者
  • TypeScript中的函数重载实现:Naive Ui Admin多参数处理实战指南 [特殊字符]
  • 视频捕获新范式:猫抓Cat-Catch的技术原理与实战应用
  • VS Code插件搬家指南:如何用软链接解放C盘空间(附CMD命令详解)
  • 零信任安全落地实战:企业如何构建无边界可信访问体系
  • translategemma-4b-it惊艳展示:手写体英文便签→结构化中文翻译结果
  • BlinkingLED:嵌入式系统硬件抽象与时间控制实践范式
  • Porcupine_PT葡萄牙语唤醒引擎在Arduino Nano 33 BLE Sense上的嵌入式实现
  • 技术民主化:让每个人都能轻松掌控Windows包管理的Winget安装工具
  • 终极指南:如何理解Apache Geode的高效通信机制
  • 终极指南:如何用Poly Haven Assets插件在Blender中快速获取高质量3D资源
  • 小米:只要21.99万起
  • Nitro社区贡献指南:参与开源项目的入门步骤
  • Chord - Ink Shadow 故障诊断指南:遇到“403 Forbidden”等API错误如何解决
  • MangoHud与Linux发行版定制工具:Kiwi、Cubic使用指南
  • Anaconda3安装后PowerShell报错?手把手教你修复conda-hook.ps1路径问题
  • 嵌入式C语言中for(;;)与while(1)的本质差异与工程选择