根據資訊系統和資料庫安全維護要求,需要定期修改資料庫賬戶密碼,修改mysql(5.7.x版本)賬戶密碼的三種方式,
試驗環境說明:
mysql資料庫版本:5.7.32
方法一:用mysqladmin在作業系統視窗下修改
格式:mysqladmin -u用戶名 -p舊密碼 password 新密碼
例子:mysqladmin -utest -p password ‘123qwe’
[test@testenv ~]$ mysqladmin -u test -p password ‘123qwe’
Enter password:
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
方法二: 用SET PASSWORD命令在mysql視窗下修改
首先登錄MySQL,
格式:mysql> set password for 用戶名@‘host’ = password(‘新密碼’);
例子:mysql> set password for test@’%’= password(‘123456’);
mysql> set password for test@’%’ = password(‘123456’);
Query OK, 0 rows affected, 1 warning (0.00 sec)
方法三:用UPDATE直接編輯mysql庫user表修改
首先登錄MySQL,
mysql> use mysql;
mysql> update user set authentication_string=password(‘654321’) where user=‘test’ and host=’%’;
mysql> flush privileges;
此方法因為需要mysql庫的寫權限,需要管理員執行操作,
mysql> update user set authentication_string=password(‘654321’) where user=‘test’ and host=’%’;
Query OK, 0 rows affected, 1 warning (0.01 sec)
Rows matched: 1 Changed: 0 Warnings: 1
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/234365.html
標籤:其他
上一篇:單點接地 or 多點接地?
