Get the App
SLTechnology News&Howtos  ›  Database  › 

Centos7 change mysql password and modify Policy

Shulou Source: shulou.com Published: 2022-06-01 09:05:10 11月02日 Update

After centos7, MySQL (5.7) installed through yum source, log in MySQL for the first time, you need to check the log file first, find the temporary password, and then modify the password after logging in. Or, modify the password policy, of course, you also choose not to modify the password policy, I am doing testing, so simple password is more convenient. The specific operation is as follows:

Change password:

Start MySQL

2. View temporary password

grep 'temporary password' /var/log/mysqld.log

2017-05-06T05:58:54.621766Z 1 [Note] A temporary password is generated for root@localhost: +AqLt/ftS1)k

3. Log in to MySQL with a temporary password

mysql -u root -p +AqLt/ftS1

4. Change password

ALTER USER 'root'@'localhost' IDENTIFIED BY '123';

5. Test landing

Modify password policy: (Temporary password must be modified first before password policy can be viewed, before simple password can be modified!!!)

1. View current password policy

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_check_user_name | 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 |

+---------------------------------------+--------+

2. Modify the policy (add the following statement to the configuration file)

vi /etc/my.conf

validate_password = off

Description: off or OFF; 0 or LOW; 1 or MEDIUM; 2 or STRONG

MySQL official website password policy details: dev.mysql.com/doc/refman/5.7/en/validate-password-options-variables.html#sysvar_validate_password_policy

Tags: Password policy login file test log version statement secondary login network secret selection configuration Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Shulou Tech Info NVidia OPPO Reno Docker