您的位置:首页 > 数据库 > MySQL

MySQL——修改root密码的3种方法

2017-08-14 20:52 309 查看
方法1: 用SET PASSWORD命令

首先登录MySQL。

格式:mysql> set password for 用户名@localhost = password('新密码');

例子:mysql> set password for root@localhost = password('123');

方法2:用mysqladmin

格式:mysqladmin -u用户名 -p旧密码 password 新密码

例子:mysqladmin -uroot -p123456 password 123

方法3:用UPDATE直接编辑user表

首先登录MySQL。

mysql> use mysql;
mysql> update user set password=password('123') where user='root' and host='localhost';

或者      update user set authentication_string=authentication_string('123') where user='root' and host='localhost';

mysql> flush privileges;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: