Mysql之账户密码修改
日期: 2020-12-13 分类: 跨站数据测试 466次阅读
根据信息系统和数据库安全维护要求,需要定期修改数据库账户密码。修改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)
除特别声明,本站所有文章均为原创,如需转载请以超级链接形式注明出处:SmartCat's Blog
上一篇: 技术经理成长复盘-大重构
下一篇: mysql中操作表的常用sql
精华推荐