MySQL8.0.16賬戶雙密碼實(shí)驗(yàn)一例

從MySQL 8.0.14開始,允許用戶帳戶擁有雙密碼,指定為主密碼和輔助密碼。

10年積累的成都做網(wǎng)站、成都網(wǎng)站制作、成都外貿(mào)網(wǎng)站建設(shè)經(jīng)驗(yàn),可以快速應(yīng)對(duì)客戶對(duì)網(wǎng)站的新想法和需求。提供各種問題對(duì)應(yīng)的解決方案。讓選擇我們的客戶得到更好、更有力的網(wǎng)絡(luò)服務(wù)。我雖然不認(rèn)識(shí)你,你也不認(rèn)識(shí)我。但先網(wǎng)站制作后付款的網(wǎng)站建設(shè)流程,更有白銀區(qū)免費(fèi)網(wǎng)站建設(shè)讓你可以放心的選擇與我們合作。

雙密碼功能可以在以下場(chǎng)景中無縫地執(zhí)行憑證更改:

系統(tǒng)有大量MySQL服務(wù)器,可能涉及主從復(fù)制

多個(gè)應(yīng)用程序連接到不同的MySQL服務(wù)器

必須對(duì)應(yīng)用程序用于連接服務(wù)器的帳戶進(jìn)行定期密碼更改


實(shí)驗(yàn)如下:


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)






開另外一個(gè)session:


兩個(gè)密碼都可以登錄:


# 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)




開另外一個(gè)會(huì)話,用舊密碼登錄報(bào)錯(cuò):


# 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保留帳戶當(dāng)前密碼作為其輔助密碼,替換任何現(xiàn)有的二級(jí)密碼。新密碼將成為主密碼,

但客戶端可以使用該帳戶使用主密碼或輔助密碼連接到服務(wù)器。

對(duì)于ALTER USER, DISCARD OLD PASSWORD丟棄二級(jí)密碼(如果存在)。該帳戶僅保留其主密碼,客戶端可以使用

該帳戶僅使用主密碼連接到服務(wù)器。


網(wǎng)頁(yè)題目:MySQL8.0.16賬戶雙密碼實(shí)驗(yàn)一例
文章URL:http://muchs.cn/article34/ihsgpe.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供ChatGPT、云服務(wù)器商城網(wǎng)站、外貿(mào)網(wǎng)站建設(shè)、App設(shè)計(jì)、網(wǎng)站收錄

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

商城網(wǎng)站建設(shè)