MySQL 5.7 Initialization operation (root initial password, change password, password policy, turn off IPV6 monitoring)

Source: Internet
Author: User

I am here to install the Mysql-community-server through the official source of the MySQL yum, the current version is MySQL 5.7.12.

wget rpm-ivh Mysql57-community-release-el6-8.noarch.rpmyum Install Mysql-community-serverservice mysqld start

After the first boot there will be an initialization process that will generate a random password for the root account.


To enhance security, MySQL5.7 randomly generated a password for the root user, in Error_log, about the location of Error_log, if the RPM package is installed, the default is/var/log/mysqld.log.

650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M02/82/03/wKiom1dHsWrzxcaDAAATxQllKbM712.png-wh_500x0-wm_3 -wmp_4-s_1497573554.png "title=" 1.png "alt=" Wkiom1dhswrzxcadaaatxqllkbm712.png-wh_50 "/>

Find the generated random password

650) this.width=650; "Src=" http://s2.51cto.com/wyfs02/M02/82/02/wKioL1dHs3_ B09e4aabeqyk_new596.png "title=" 2.png "alt=" Wkiol1dhs3_b09e4aabeqyk_new596.png "/>

Mysql -u root -p ' zxmgg% #L3 =;1 ' Mysql: [warning] using a password on  the command line interface can be insecure. Welcome to the mysql monitor.  commands end with ; or \ g.your mysql connection id is 4server version: 5.7.12copyright  (c)  2000, 2016, oracle and/or its affiliates. all rights reserved. oracle is a registered trademark of oracle corporation and/or  Itsaffiliates. other names may be trademarks of their respectiveowners . type  ' help; '  or  ' \h '  for help. Type  ' \c '  to clear the current input  statement.mysql> show databases; error 1820  (HY000):  you must reset your password using&nbsp alter user statement before executing this statement.mysql> show  Databases error 1820  (HY000):  you must reset your password using alter  user statement before executing this statement.

After landing, the normal operation will be limited, prompting you must change the password before you can operate.

OK, follow the prompts to change the password:

mysql> SET PASSWORD = PASSWORD (' 123456 '); ERROR 1819 (HY000): Your password does not satisfy the current policy requirementsmysql> SET password = password ("root" ); ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

However, the password set is not allowed according to the current password policy.

After reviewing the official documentation, we found the following three password policies:

policy tests performed
0  or  low length
1  or  medium length; Numeric, lowercase/uppercase, and special characters
2OrSTRONG Length; Numeric, lowercase/uppercase, and special characters; Dictionary file

The current password policy defaults to 1, which is MEDIUM

Mysql [email protected]:(None) > show VARIABLES like  "%password%" +------------ ---------------------------+---------+| variable_name                          |  value   | | ---------------------------------------+---------||  default_password_lifetime             |  0       | |  disconnect_on_expired_password        | ON       | |  log_builtin_as_identified_by_password | off     | |  mysql_native_password_proxy_users     | off     | |  old_passwords                         | 0        | |  report_password                        |         | |  sha256_password_proxy_users           | off      | |  validate_password_dictionary_file     |          | |  validate_password_length               | 8       | |  validate_password_mixed_case_count    | 1        | |  validate_password_number_count        | 1        | |  validate_password_policy               | medium  | |  validate_password_special_char_count  | 1       |+---- -----------------------------------+---------+13 rows in settime: 0.030s

So your policy to change the password is a number of lowercase letters with a special character length of at least 8 bits .

After you change the password, you can do the database operation.

MySQL [email protected]:(none) > show databases;+--------------------+| Database | | --------------------|| Information_schema | | MySQL | | Performance_schema | | SYS |+--------------------+4 rows in settime:0.009s


Next, modify the default password policy (the actual environment is not recommended to be modified to a lower security policy)

MySQL [email protected]:(None) > Set global validate_password_policy = 0; Query OK, 0 rows affectedtime:0.003s

Now that the default password policy is set, only the password length is limited . The default is a character length of at least 8 bits.

which

Validate_password_number_count Specifies the length of the data in the password ,

Validate_password_special_char_count Specifies the length of the special characters in the password ,

Validate_password_mixed_case_count Specifies the length of the size letter in the password .


These parameters, the default value is 1, so the Validate_password_length minimum value is 4, if you explicitly specify that the value of validate_password_length is less than 4, although there is no error, but Validate_password_ The value of length will be set to 4.

MySQL [email protected]:(None) > Set global validate_password_length = 3; Query OK, 0 rows affectedtime:0.004smysql [email protected]ost: (none) > show VARIABLES like "Validate_password_length" +--------------------------+---------+|   variable_name | Value | | --------------------------+---------||       Validate_password_length | 4 |+--------------------------+---------+1 row in settime:0.010s

If you modify the Validate_password_number_count,validate_password_special_char_count,validate_password_mixed_case_ Any value in count, Validate_password_length is dynamically modified.


MySQL 5.7 Installs the Validate_password plugin by default. So more than the above steps.


----------------------------------------------------------------------------

To set the level of password policy through the MY.CNF configuration file

"/etc/my.cnf"  28L, 987C                                                                                                                                                                                                 22,1          All# For  advice on how to change settings please see# http://dev.mysql.com/doc/ Refman/5.7/en/server-configuration-defaults.html[mysqld]## remove leading # and set  to the amount of RAM for the most important data#  cache in mysql. start at 70% of total ram for dedicated  server, else 10%.# innodb_buffer_pool_size = 128m## remove leading  # to turn on a very important data integrity option:  logging# changes to the binary log between backups.# log_bin##  Remove leading # tO set options mainly useful for reporting servers.# the server  defaults are faster for transactions and fast selects.# adjust  sizes as needed, experiment to find the optimal values.#  join_buffer_size = 128m# sort_buffer_size = 2m# read_rnd_buffer_size =  2mdatadir=/var/lib/mysqlsocket=/var/lib/mysql/mysql.sockvalidate_password_policy=2

The last line Validate_password_policy sets the password policy level when MySQL starts. If set to 3, the dictionary file needs to be specified.


Of course you can also close the Validate_password plugin via the my.cnf configuration file.

Just add a row

Validate_password = Off

After editing the configuration file, restart the MYSQLD service to take effect.

MySQL [email protected]:(none) > show VARIABLES like "validate_password%" +-----------------+---------+| variable_name | Value | | -----------------+---------|+-----------------+---------+0 rows in settime:0.008s

After you close the Validate_password plug-in, there are no parameter variables for Validate_password.


MySQL official introduction to the use of the Validate_password plugin:

Http://dev.mysql.com/doc/refman/5.6/en/validate-password-plugin.html#option_mysqld_validate-password


.

This article is from the "Professor" blog, please be sure to keep this source http://professor.blog.51cto.com/996189/1783769

MySQL 5.7 Initialization operation (root initial password, change password, password policy, turn off IPV6 monitoring)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.