MySQL8.0.16アカウントのパスワードの二重の実験1ケース

ユーザーアカウントは、プライマリおよびセカンダリパスワードパスワードとして指定し、二重のパスワードを持ってできるようにするのMySQL 8.0.14を、開始します。

デュアルパスワード機能は、次のシナリオで資格情報を変更シームレスに行うことができます。

MySQLサーバシステムの多くがありますが、マスター・スレーブ複製に関与することができます

複数のアプリケーションサーバは、別のMySQLへの接続します

変更のためのサーバーアプリケーションに接続するために、通常のアカウントのパスワードを行わなければなりません 

次のように実験は以下のとおりです。 

MySQLのバージョン:

MySQLの>を選択したバージョン();

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

| バージョン()|

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

| 8.0.16 |

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

セット内の1行(0.00秒)

mysqlの> '123456' で識別される '%' @ rootユーザを作成します。

影響を受けたクエリOK、0行(0.25秒)

MySQLの> *上のすべての権限を付与* '%' @ rootに。

影響を受けたクエリOK、0行(0.10秒)

MySQLの>「ルート」で識別される「%」@ rootユーザーが現在のパスワードを変更するRETAIN。

影響を受けたクエリOK、0行(0.28秒)

別のセッションを開きます。

鄭州ウィメンズ病院ます。http://byby.zztjyy.com/zztjyy///

二つのパスワードは、ログインすることができます:

#mysqlの-uroot -p123456 -h 192.168.140.52

mysqlの:[警告]コマンドラインインターフェイス上でパスワードを使用するには安全でないことができます。

MySQLのモニタへようこそ。コマンドは、で終わります。や\ g。

MySQLの接続IDが21であります

Server version: 8.0.16 MySQL Community Server - GPL

Copyright (c) 2000, 2019, 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>\q

Bye

[root@test2 ~]# mysql -uroot -proot -h 192.168.140.52

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 22

Server version: 8.0.16 MySQL Community Server - GPL

Copyright (c) 2000, 2019, 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>\q

Bye

丢弃旧密码:

mysql>alter user root@'%' DISCARD OLD PASSWORD;

Query OK, 0 rows affected (0.12 sec)开另外一个会话,用旧密码登录报错:

# mysql -uroot -p123456 -h 192.168.140.52

mysql: [Warning] Using a password on the command line interface can be insecure.

ERROR 1045 (28000): Access denied for user 'root'@'192.168.140.52' (using password: YES)

新密码可以登录:

# mysql -uroot -p123456 -h 192.168.140.52

mysql: [Warning] Using a password on the command line interface can be insecure.

ERROR 1045 (28000): Access denied for user 'root'@'192.168.140.52' (using password: YES)

[root@test2 ~]# 

[root@test2 ~]# 

[root@test2 ~]# mysql -uroot -proot -h 192.168.140.52

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 27

Server version: 8.0.16 MySQL Community Server - GPL

Copyright (c) 2000, 2019, 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>\q

Bye

备注:

RETAIN CURRENT PASSWORD保留帐户当前密码作为其辅助密码,替换任何现有的二级密码。新密码将成为主密码,

但客户端可以使用该帐户使用主密码或辅助密码连接到服务器。

对于ALTER USER, DISCARD OLD PASSWORD丢弃二级密码(如果存在)。该帐户仅保留其主密码,客户端可以使用

该帐户仅使用主密码连接到服务器。


おすすめ

転載: blog.51cto.com/14337177/2407422