ITPub博客

首页 > 数据库 > MySQL > MySQL5.7.11 -- 严格的密码要求

MySQL5.7.11 -- 严格的密码要求

MySQL 作者:urgel_babay 时间:2016-02-29 16:52:55 0 删除 编辑
2016.02.27
今天接着学习MySQL,前天安装完了MySQL 5.7.11,在此基础进一步了解新版本MySQL的各项改变。

5.7.11对密码有了更严格的要求,分为LOW,MEDIUM,STRONG三个等级,对应要求如下:
LOW    Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary file

由于前天安装MySQL的时候,是按照以往的5.6经验流程,所以密码设置都是比较一般,现在开始按照5.7.11的要求设置密码
  1. [root@zhangMySQL5711 bin]# ./mysql_secure_installation         //此文件在/usr/local/mysql/bin 目录下
  2. Securing the MySQL server deployment.

  3. Connecting to MySQL server using password in '/root/.mysql_secret'      //提示使用安装时,MySQL提供的随机密码
  4. Error: Access denied for user 'root'@'localhost' (using password: YES)
  5. [root@zhangMySQL5711 bin]# more /root/.mysql_secret
  6. # Password set for user 'root@localhost' at 2016-02-24 17:49:00
  7. E>_iG6u+<%dh
  8. [root@zhangMySQL5711 bin]# ./mysql_secure_installation --help             //help 查看一下相关的参数选项,这里不多解释每一项,平时用到的也就那么熟悉的几项
  9. ./mysql_secure_installation Ver 5.7.11, for Linux on x86_64
  10. Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.

  11. Oracle is a registered trademark of Oracle Corporation and/or its
  12. affiliates. Other names may be trademarks of their respective
  13. owners.
  14. MySQL Configuration Utility.Usage: ./mysql_secure_installation [OPTIONS]
  15.   -?, --help Display this help and exit.
  16.   -h, --host=name Connect to host.
  17.   -p, --password[=name]
  18.                       Password to connect to the server. If password is not
  19.                       given it's asked from the tty.
  20.   -P, --port=# Port number to use for connection or 0 for default to, in
  21.                       order of preference, my.cnf, $MYSQL_TCP_PORT,
  22.                       /etc/services, built-in default (3306).
  23.   --protocol=name The protocol to use for connection (tcp, socket, pipe,
  24.                       memory).
  25.   -S, --socket=name Socket file to be used for connection.
  26.   --ssl-mode=name SSL connection mode.
  27.   --ssl Deprecated. Use --ssl-mode instead.
  28.                       (Defaults to on; use --skip-ssl to disable.)
  29.   --ssl-verify-server-cert
  30.                       Deprecated. Use --ssl-mode=VERIFY_IDENTITY instead.
  31.   --ssl-ca=name CA file in PEM format.
  32.   --ssl-capath=name CA directory.
  33.   --ssl-cert=name X509 cert in PEM format.
  34.   --ssl-cipher=name SSL cipher to use.
  35.   --ssl-key=name X509 key in PEM format.
  36.   --ssl-crl=name Certificate revocation list.
  37.   --ssl-crlpath=name Certificate revocation list path.
  38.   --tls-version=name TLS version to use, permitted values are: TLSv1, TLSv1.1
  39.   -u, --user=name User for login if not root.
  40.   -D, --use-default Execute with no user interactivity

  41. Default options are read from the following files in the given order:
  42. /etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf
  43. The following groups are read: mysql_secure_installation mysql client
  44. The following options may be given as the first argument:
  45. --print-defaults Print the program argument list and exit.
  46. --no-defaults Don't read default options from any option file,
  47.                         except for login file.
  48. --defaults-file=# Only read default options from the given file #.
  49. --defaults-extra-file=# Read this file after the global files are read.
  50. --defaults-group-suffix=#
  51.                         Also read groups with concat(group, suffix)
  52. --login-path=# Read this path from the login file.

  53. Variables (--variable-name=value)
  54. and boolean options {FALSE|TRUE} Value (after reading options)
  55. --------------------------------- ----------------------------------------
  56. host localhost
  57. port 0
  58. socket (No default value)
  59. ssl TRUE
  60. ssl-verify-server-cert FALSE
  61. ssl-ca (No default value)
  62. ssl-capath (No default value)
  63. ssl-cert (No default value)
  64. ssl-cipher (No default value)
  65. ssl-key (No default value)
  66. ssl-crl (No default value)
  67. ssl-crlpath (No default value)
  68. tls-version (No default value)
  69. user root
  70. use-default FALSE
  71. [root@zhangMySQL5711 bin]# ./mysql_secure_installation -uroot -p                // 尝试登录,使用安装后我自己的密码:zhangmysql
  72. Enter password:

  73. Securing the MySQL server deployment.

  74. Error: Access denied for user 'root'@'localhost' (using password: YES)          //登录失败,说明使用mysql_secure_installation方式登录,原来的密码已经不能使用了
  75. [root@zhangMySQL5711 bin]# ./mysql_secure_installation -uroot -p                //再次登录,使用安装是MySQL自己提供的随机密码:E>_iG6u+<%dh     登录成功!
  76. Enter password:

  77. Securing the MySQL server deployment.


  78. VALIDATE PASSWORD PLUGIN can be used to test passwords                        //密码验证插件,为了提高安全性,需要验证密码
  79. and improve security. It checks the strength of password                      // 它会检查密码的强度
  80. and allows the users to set only those passwords which are                    //只允许用户设置足够安全的密码
  81. secure enough. Would you like to setup VALIDATE PASSWORD plugin?              //提示安装密码验证插件

  82. Press y|Y for Yes, any other key for No: y

  83. There are three levels of password validation policy:                      //三个等级的验证策略

  84. LOW Length >= 8                                                             //最小长度大于等于8个字符
  85. MEDIUM Length >= 8, numeric, mixed case, and special characters             //数字,字母,特殊字符 混合,具体的应该是至少1个数字,1个字母,1个特殊字符,长度不超过32个字符
  86. STRONG Length >= 8, numeric, mixed case, special characters and dictionary file   //  最严格,加上了,字典文件

  87. Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2                      //这里我选择2 MEDIUM
  88. Using existing password for root.

  89. Estimated strength of the password: 50                                   //这里也是密码强度的评级
  90. Change the password for root ? ((Press y|Y for Yes, any other key for No) : y

  91. New password:                                                        //我这里输入的是:Zhangmysql57

  92. Re-enter new password:

  93. Estimated strength of the password: 50
  94. Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y     //提示要使用刚刚输入的密码吗?
  95.  ... Failed! Error: Your password does not satisfy the current policy requirements                   //插件验证不通过,不符合当前安全要求级别

  96. New password:                                                        //我这里输入的是:Zhangmysql_57

  97. Re-enter new password:

  98. Estimated strength of the password: 100
  99. Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
  100. By default, a MySQL installation has an anonymous user,               //默认情况下,MySQL有一个匿名用户,
  101. allowing anyone to log into MySQL without having to have              //这个匿名用户,不必有一个用户为他们创建,匿名用户允许任何人登录到MySQL,
  102. a user account created for them. This is intended only for            //这只是为了方便测试使用
  103. testing, and to make the installation go a bit smoother.
  104. You should remove them before moving into a production                //在正式环境使用的时候,建议你移除它
  105. environment.

  106. Remove anonymous users? (Press y|Y for Yes, any other key for No) : y                //提示移除匿名用户
  107. Success.

  108. Normally, root should only be allowed to connect from                        //一般情况下,root用户只允许使用"localhost"方式登录,
  109. 'localhost'. This ensures that someone cannot guess at                       // 以此确保,不能被某些人通过网络的方式访问
  110. the root password from the network.

  111. Disallow root login remotely? (Press y|Y for Yes, any other key for No) : n          //

  112.  ... skipping.
  113. By default, MySQL comes with a database named 'test' that                      //默认情况下,MySQL数据库中有一个任何用户都可以访问的test库,
  114. anyone can access. This is also intended only for testing,                     //这也仅仅是为了测试
  115. and should be removed before moving into a production                          // 在正式环境下,应该移除掉
  116. environment.


  117. Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
  118.  - Dropping test database...
  119. Success.

  120.  - Removing privileges on test database...
  121. Success.

  122. Reloading the privilege tables will ensure that all changes                           //刷新权限表,以确保所有的修改可以立刻生效
  123. made so far will take effect immediately.

  124. Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
  125. Success.

  126. All done!
  127. [root@zhangMySQL5711 bin]
到此,密码修改完成了,现在去尝试登录,看是否是如此。

  1. [root@zhangMySQL5711 ~]# mysql -uroot -p                              //使用第一次安装时候的密码:zhangmysql
  2. Enter password:
  3. ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
  4. [root@zhangMySQL5711 ~]# mysql -uroot -p                              //使用 安装MySQL要求设置的密码 :Zhangmysql_57
  5. Enter password:
  6. Welcome to the MySQL monitor. Commands end with ; or \g.
  7. Your MySQL connection id is 17
  8. Server version: 5.7.11 Source distribution

  9. Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

  10. Oracle is a registered trademark of Oracle Corporation and/or its
  11. affiliates. Other names may be trademarks of their respective
  12. owners.

  13. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

  14. mysql> show databases;                         //显示没有了test库
  15. +--------------------+
  16. | Database |
  17. +--------------------+
  18. | information_schema |
  19. | mysql |
  20. | performance_schema |
  21. | sys |
  22. +--------------------+
  23. 4 rows in set (0.00 sec)

  24. mysql> select user ,host from mysql.user;                     //root用户只有"localhost"
  25. +-----------+-----------+
  26. | user | host |
  27. +-----------+-----------+
  28. | zhang | % |
  29. | mysql.sys | localhost |
  30. | root | localhost |
  31. | zhang | localhost |
  32. +-----------+-----------+
  33. 4 rows in set (0.00 sec)

  34. mysql>  GRANT ALL PRIVILEGES ON *.* TO root@"%" ;                         
    ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
    mysql>  GRANT ALL PRIVILEGES ON *.* TO root@"%"  IDENTIFIED BY "Zhangmysql_57";
    Query OK, 0 rows affected, 1 warning (0.00 sec)
可以确定,上面的步骤全部生效了,其实说白了,就是要把密码设置的复杂一些,就这!

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/30936525/viewspace-2016528/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: 没有了~
请登录后发表评论 登录
全部评论

注册时间:2016-02-29

  • 博文量
    203
  • 访问量
    339114