使用set password命令
- 修改本地密码:
SET PASSWORD FOR 'root'@'localhost'=PASSWORD('newpasswd');
- 远程密码修改:
SET PASSWORD FOR 'root'@'%'=PASSWORD('newpasswd');
注意: 两个密码是相互独立的,登录时候要注意区分;
MySQL账户名组成:用户名@主机名
使用UPDATE 修改mysql.user表
USE mysql;
UPDATE user SET PASSWORD=PASSWORD('newpassword') WHERE user='root';
-- 刷新权限
FLUSH PRIVILEGES;
注意:这里将所有user为root的账号密码都修改了哦;