网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

MySQL8.0.16账户双密码实验一例-创新互联

从MySQL 8.0.14开始,允许用户帐户拥有双密码,指定为主密码和辅助密码。

平山ssl适用于网站、小程序/APP、API接口等需要进行数据传输应用场景,ssl证书未来市场广阔!成为创新互联公司的ssl证书销售渠道,可以享受市场价格4-6折优惠!如果有意向欢迎电话联系或者加微信:13518219792(备注:SSL证书合作)期待与您的合作!

双密码功能可以在以下场景中无缝地执行凭证更改:

系统有大量MySQL服务器,可能涉及主从复制

多个应用程序连接到不同的MySQL服务器

必须对应用程序用于连接服务器的帐户进行定期密码更改

实验如下:

mysql版本:

mysql>select version();

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

| version() |

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

| 8.0.16    |

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

1 row in set (0.00 sec)

mysql>create user root@'%' identified by '123456';

Query OK, 0 rows affected (0.25 sec)

mysql>grant all privileges on *.* to root@'%';

Query OK, 0 rows affected (0.10 sec)

mysql>alter user root@'%' identified by 'root' RETAIN CURRENT PASSWORD;

Query OK, 0 rows affected (0.28 sec)

开另外一个session:

两个密码都可以登录:

# mysql -uroot -p123456 -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 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丢弃二级密码(如果存在)。该帐户仅保留其主密码,客户端可以使用

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



名称栏目:MySQL8.0.16账户双密码实验一例-创新互联
文章链接:http://bjjierui.cn/article/cchiph.html

其他资讯