我们相信:世界是美好的,你是我也是。平行空间的世界里面,不同版本的生活也在继续...

苏南大叔的测试机上,用brew安装的mysql默认密码还是空的。所以,这里,用mysql的安全设置命令进行了下设置。大家可以一并来学习一下这个命令。

苏南大叔:mysql安全设置命令mysql_secure_installation使用指南 - mysql-secure-installation
mysql安全设置命令mysql_secure_installation使用指南(图8-1)

mysql_secure_installation

整个过程比较简单,需要简单的和终端进行些交互。下面的截图是建立于纯新安装的无密码的mysql环境。如果您的mysql环境是有密码的,或者进行过类似设置,界面是不一样的。有一定的区别。

建立密码验证插件

苏南大叔:mysql安全设置命令mysql_secure_installation使用指南 - 000
mysql安全设置命令mysql_secure_installation使用指南(图8-2)

选择密码规则

苏南大叔:mysql安全设置命令mysql_secure_installation使用指南 - 001
mysql安全设置命令mysql_secure_installation使用指南(图8-3)

创建符合上述选择好规则的新密码

苏南大叔:mysql安全设置命令mysql_secure_installation使用指南 - 002
mysql安全设置命令mysql_secure_installation使用指南(图8-4)

删除匿名用户

苏南大叔:mysql安全设置命令mysql_secure_installation使用指南 - 003
mysql安全设置命令mysql_secure_installation使用指南(图8-5)

禁用远程root登录

苏南大叔:mysql安全设置命令mysql_secure_installation使用指南 - 004
mysql安全设置命令mysql_secure_installation使用指南(图8-6)

删除测试数据表

苏南大叔:mysql安全设置命令mysql_secure_installation使用指南 - 005
mysql安全设置命令mysql_secure_installation使用指南(图8-7)

done

苏南大叔:mysql安全设置命令mysql_secure_installation使用指南 - 006
mysql安全设置命令mysql_secure_installation使用指南(图8-8)

localhost:~ sunan$ sudo mysql_secure_installation
Password:

Securing the MySQL server deployment.

Connecting to MySQL using a blank password.

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

There are three levels of 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: 0
Please set the password for root here.

New password:

Re-enter new password:
Sorry, passwords do not match.

New password:

Re-enter new password:

Estimated strength of the password: 25
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
 ... Failed! Error: Your password does not satisfy the current policy requirements

New password:

Re-enter new password:
Sorry, passwords do not match.

New password:

Re-enter new password:

Estimated strength of the password: 50
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
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
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相关内容,请点击查看:

如果本文对您有帮助,或者节约了您的时间,欢迎打赏瓶饮料,建立下友谊关系。
本博客不欢迎:各种镜像采集行为。请尊重原创文章内容,转载请保留作者链接。

 【福利】 腾讯云最新爆款活动!1核2G云服务器首年50元!

 【源码】本文代码片段及相关软件,请点此获取更多信息

 【绝密】秘籍文章入口,仅传授于有缘之人   mysql