2021-11-18 11:31:51 版本 : Mysql5修改root账户密码
作者: 系统管理员 于 2018年09月23日 发布在分类 / 配置安装 / 数据库及SQL脚本 / mysql / 设置 下,并于 2021年11月18日 编辑
 历史版本

备注 修改日期 修改人
格式调整 2021-11-18 11:31:51[当前版本] 系统管理员
格式调整 2019-01-21 19:48:05 系统管理员
CREAT 2018-09-23 16:26:20 系统管理员

修改root账户密码
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpassword');
第一种方法:
mysqladmin -u root -pnewpass  password "redhat"

第二种方法:使用set password命令:
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpass');
Query OK, 0 rows affected (0.00 sec)

第三种方法:使用update user直接登录数据库修改密码:
mysql> update user set password = password('newpass') where user = 'root';
Query OK, 5 rows affected (0.01 sec)
Rows matched: 5  Changed: 5  Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> \q
历史版本-目录  [回到顶端]
    wcp知识库系统-京ICP备15024440号-1 -V 5.1.9 -wcp