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 服务器的安全性。

参考资源链接:[MySQL 8.0.11 RPM安装配置全攻略](https://wenku.csdn.net/doc/645ca01f95996c03ac3e1f17?utm_source=wenku_answer2doc_content) 在开始安装MySQL之前,了解系统的需求和安装步骤至关重要。为了详细指导你在RHEL6.5系统上通过RPM方式安装MySQL 8.0.11社区版,并正确配置以及使用`mysql_secure_installation`来增强数据库安全性,强烈建议参阅这份资源:《MySQL 8.0.11 RPM安装配置全攻略》。这本教程将为你提供完整的操作步骤,确保你能够顺利地完成安装和配置过程。 首先,确保你已经在RHEL6.5系统上下载并解压缩了适合的操作系统版本的RPM包。然后,按照正确的顺序安装MySQL组件。可以通过`yum`或`rpm`命令来安装这些包,确保每个包都安装无误。 安装完成后,你需要启动MySQL服务并设置为开机自启。这可以通过`systemctl`命令轻松完成。启动MySQL服务后,使用`mysql_secure_installation`脚本来加强系统的安全性。这个脚本会引导你执行几个关键步骤,包括设置root密码、移除匿名用户、禁止root用户远程登录以及删除测试数据库。这些步骤对于保护你的MySQL服务器免受未授权访问至关重要。 最后,使用`mysql`命令行客户端测试安装是否成功。如果可以成功登录并执行基本的数据库操作,说明MySQL已经正确安装并配置完成。 关于MySQL 8.0.11的新特性和改进,本教程也有所涉及,有助于你更好地利用MySQL的最新功能来满足应用需求。安装过程中的任何疑问,你也可以参考《MySQL 8.0.11 RPM安装配置全攻略》中的故障排除部分,其中提供了常见问题的解决方案和建议。 参考资源链接:[MySQL 8.0.11 RPM安装配置全攻略](https://wenku.csdn.net/doc/645ca01f95996c03ac3e1f17?utm_source=wenku_answer2doc_content)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

黑蛋同志

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值