博客
关于我
MySQL 的mysql_secure_installation安全脚本执行过程介绍
阅读量:795 次
发布时间:2023-02-11

本文共 2666 字,大约阅读时间需要 8 分钟。

优化后的内容:

以下是执行 mysql_secure_installation 的详细步骤,帮助您安全配置 MySQL 服务器:

1. 启动 MySQL 安全脚本

打开终端,执行以下命令以启动 MySQL 安全配置工具:

sudo mysql_secure_installation

2. 输入当前 MySQL root 密码

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

3. 设置新的 root 密码

脚本会提示您是否要设置新的 root 密码。建议设置一个强密码以提高安全性。输入 Y 并按 Enter,然后按照提示设置您的新密码。

4. 删除匿名用户

匿名用户允许任何人登录 MySQL,这通常用于测试。请执行以下操作以删除匿名用户:

Y

按 Enter 确认操作。

5. 禁止 root 用户远程登录

为了提升安全性,建议禁止 root 用户从远程设备登录。执行以下操作:

Y

按 Enter 确认。

6. 删除测试数据库

默认安装的 test 数据库允许任何用户访问,建议在生产环境中删除它。执行以下操作:

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 可以用于测试密码并提高安全性。它检查密码的强度,并确保用户只能设置安全强的密码。Would you like to setup VALIDATE PASSWORD pluginPress y|Y for Yes, any other key for No: Y (根据需要选择是否启用密码验证插件)Please set the password validation policy:LOW Length >= 8MEDIUM Length >= 8, numeric, mixed case, and special charactersSTRONG Length >= 8, numeric, mixed case, special characters and dictionary filePlease enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 1 (选择密码验证策略)Using existing password for root.Estimated strength of the password: 100Change 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 anyoneto log into MySQL without having to have a user account created forthem. This is intended only for testing, and to make the installationgo a bit smoother. You should remove them before moving into aproduction 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’. Thisensures 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 canaccess. This is also intended only for testing, and should be removedbefore 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 farwill 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://efbfk.baihongyu.com/

你可能感兴趣的文章
MySQL 是如何加锁的?
查看>>
MySQL 是怎样运行的 - InnoDB数据页结构
查看>>
mysql 更新子表_mysql 在update中实现子查询的方式
查看>>
MySQL 有什么优点?
查看>>
mysql 权限整理记录
查看>>
mysql 权限登录问题:ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: YES)
查看>>
MYSQL 查看最大连接数和修改最大连接数
查看>>
MySQL 查看有哪些表
查看>>
mysql 查看锁_阿里/美团/字节面试官必问的Mysql锁机制,你真的明白吗
查看>>
MySql 查询以逗号分隔的字符串的方法(正则)
查看>>
MySQL 查询优化:提速查询效率的13大秘籍(避免使用SELECT 、分页查询的优化、合理使用连接、子查询的优化)(上)
查看>>
mysql 查询数据库所有表的字段信息
查看>>
【Java基础】什么是面向对象?
查看>>
mysql 查询,正数降序排序,负数升序排序
查看>>
MySQL 树形结构 根据指定节点 获取其下属的所有子节点(包含路径上的枝干节点和叶子节点)...
查看>>
mysql 死锁 Deadlock found when trying to get lock; try restarting transaction
查看>>
mysql 死锁(先delete 后insert)日志分析
查看>>
MySQL 死锁了,怎么办?
查看>>
MySQL 深度分页性能急剧下降,该如何优化?
查看>>
MySQL 深度分页性能急剧下降,该如何优化?
查看>>