1.设置 MySQL root 用户密码。 步骤 1:启动 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。 完整示例以下是一个完整的示例输出: VALIDATE PASSWORD PLUGIN can be used to test passwords and improve security. Would you like to setup VALIDATE PASSWORD plugin? Press y|Y for Yes, any other key for No: Y (根据需要选择是否启用密码验证插件) LOW Length >= 8 Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 1 (选择密码验证策略) Estimated strength of the password: 100 By default, a MySQL installation has an anonymous user, allowing anyone Remove anonymous users? (Press y|Y for Yes, any other key for No) : Y (删除匿名用户) Normally, root should only be allowed to connect from ‘localhost’. This Disallow root login remotely? (Press y|Y for Yes, any other key for No) : Y (禁止 root 用户远程登录) By default, MySQL comes with a database named ‘test’ that anyone can Remove test database and access to it? (Press y|Y for Yes, any other key for No) : Y (删除测试数据库)
Reloading the privilege tables will ensure that all changes made so far Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y (重新加载权限表) All done! 免责声明:本内容来源于网络,如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作! |