CentOS 7.4 64位安装配置MySQL8.0(7)

mysql> use mysql;
Database changed
mysql> select user,host,plugin from user;
+------------------+-----------+-----------------------+
| user            | host      | plugin                |
+------------------+-----------+-----------------------+
| linuxidc-mp        | %        | caching_sha2_password |
| mysql.infoschema | localhost | caching_sha2_password |
| mysql.session    | localhost | caching_sha2_password |
| mysql.sys        | localhost | caching_sha2_password |
| root            | localhost | caching_sha2_password |
+------------------+-----------+-----------------------+
5 rows in set (0.00 sec)

mysql> ALTER USER 'linuxidc-mp'@'%' IDENTIFIED BY 'linuxidc@linuxidc.com' PASSWORD EXPIRE NEVER;
Query OK, 0 rows affected (0.04 sec)

mysql> ALTER USER 'linuxidc-mp'@'%' IDENTIFIED WITH mysql_native_password BY 'linuxidc@linuxidc.com';
Query OK, 0 rows affected (0.05 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)

mysql> show variables like '%character%';
+--------------------------+--------------------------------+
| Variable_name            | Value                          |
+--------------------------+--------------------------------+
| character_set_client    | utf8mb4                        |
| character_set_connection | utf8mb4                        |
| character_set_database  | utf8mb4                        |
| character_set_filesystem | binary                        |
| character_set_results    | utf8mb4                        |
| character_set_server    | utf8mb4                        |
| character_set_system    | utf8                          |
| character_sets_dir      | /usr/share/mysql-8.0/charsets/ |
+--------------------------+--------------------------------+
8 rows in set (0.01 sec)

这里有个问题,新密码设置的时候如果设置的过于简单会报错:

原因是因为MySQL有密码设置的规范,具体是与validate_password_policy的值有关:

MySQL完整的初始密码规则可以通过如下命令查看:

mysql> SHOW VARIABLES LIKE 'validate_password%';
+--------------------------------------+-------+
| Variable_name                        | Value |
+--------------------------------------+-------+
| validate_password_check_user_name    | OFF  |
| validate_password_dictionary_file    |      |
| validate_password_length            | 4    |
| validate_password_mixed_case_count  | 1    |
| validate_password_number_count      | 1    |
| validate_password_policy            | LOW  |
| validate_password_special_char_count | 1    |
+--------------------------------------+-------+
7 rows in set (0.01 sec)

密码的长度是由validate_password_length决定的,而validate_password_length的计算公式是:

validate_password_length = validate_password_number_count + validate_password_special_char_count + (2 * validate_password_mixed_case_count)

我的是已经修改过的,初始情况下第一个的值是ON,validate_password_length是8。可以通过如下命令修改:

mysql> set global validate_password_policy=0;
mysql> set global validate_password_length=1;

Linux公社的RSS地址https://www.linuxidc.com/rssFeed.aspx

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/fc17a92ce3c77a18c3abaf9d110daee4.html