ホームページ  >  記事  >  データベース  >  Linuxでmysqlパスワードを確認する方法

Linuxでmysqlパスワードを確認する方法

WBOY
WBOY転載
2023-05-26 23:22:493841ブラウズ

多くの友人がパスワードを忘れた経験があると思いますが、Linux で MySQL パスワードを忘れた場合はどうすればよいでしょうか?

Linux で mysql パスワードを表示する具体的な方法。

デフォルトのパスワードを表示します

grep ‘一時パスワード’ /var/log/mysqld.log

or

cat / var/log/mysqld.log | grep ‘一時パスワード’
 [root@VM_0_11_centos ~]# grep 'temporary password' /var/log/mysqld.log
 2020-05-07T16:57:52.623306Z 1 [Note] A temporary password is generated for root@localhost: Ukyool6&htfu

パスワードの変更

初めてパスワードを変更する場合は、パスワードに文字、数字を含める必要があることに注意してください。 、および特殊文字 (大文字と小文字が含まれている必要があり、長さは 8 文字未満にすることはできません)

 [root@VM_0_11_centos ~]# mysql -uroot -p
 Enter password:
 Welcome to the MySQL monitor.  Commands end with ; or \g.
 Your MySQL connection id is 1721
 Server version: 5.7.30 MySQL Community Server (GPL)
 
 Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
 
 Oracle is a registered trademark of Oracle Corporation and/or its
 affiliates. Other names may be trademarks of their respective
 owners.
 
 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 ALTER USER statement before executing this statement.
 mysql> alter user root@localhost identified by 'root!@#123';
 ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
 mysql>  SHOW VARIABLES LIKE 'validate_password%';
 ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
 mysql> alter user root@localhost identified by 'Root!@#123';
 Query OK, 0 rows affected (0.00 sec)
 
 mysql> SHOW VARIABLES LIKE 'validate_password%';
 +--------------------------------------+--------+
 | Variable_name                        | Value  |
 +--------------------------------------+--------+
 | 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      |
 +--------------------------------------+--------+
 7 rows in set (0.01 sec)
 
 mysql> use mysql;
 Reading table information for completion of table and column names
 You can turn off this feature to get a quicker startup with -A
 
 Database changed
 mysql> select Host,User from user;
 +-----------+---------------+
 | Host      | User          |
 +-----------+---------------+
 | localhost | mysql.session |
 | localhost | mysql.sys     |
 | localhost | root          |
 +-----------+---------------+
 3 rows in set (0.00 sec)
 
 mysql>

mysql パスワード ポリシー関連パラメータについて;

1)、validate_password_length は、パスワードの合計の長さを固定しました。パスワード;

2)、validate_password_dictionary_file を指定 パスワード検証用のファイル パス;

3)、validate_password_mixed_case_count パスワード全体には、少なくとも大文字と小文字の合計数が含まれている必要があります;

4)、validate_password_number_count パスワード全体には少なくともアラビア数字が含まれている必要があります;

5)、validate_password_policy はパスワードの強度検証レベルを指定します、デフォルトは MEDIUM;

の値についてvalidate_password_policy:

0/LOW: 長さのみを確認します;

1/MEDIUM: 長さ、数字、大文字と小文字、特殊文字を確認します;

2/STRONG: 長さを確認します、数字、大文字と小文字、特殊文字、辞書ファイル;

6)、validate_password_special_char_count パスワード全体には、少なくとも一定数の特殊文字が含まれている必要があります;

以上がLinuxでmysqlパスワードを確認する方法の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

声明:
この記事はyisu.comで複製されています。侵害がある場合は、admin@php.cn までご連絡ください。