mysql 修改 root 用户密码

查询用户

1
mysql> select host,user,authentication_string from mysql.user;

host: 允许用户登录的 ip‘位置’%表示可以远程;

user:当前数据库的用户名;

authentication_string: 用户密码(后面有提到此字段);

修改密码

1
ALTER user  'root'@'localhost' IDENTIFIED BY 'Cliu123#'
  1. 不需要 flush privileges 来刷新权限。
  2. 密码要包含大写字母,小写字母,数字,特殊符号。
  3. 修改成功; 重新使用用户名密码登录即可;

mysql 5.7.9 以后废弃了 password 字段和 password()函数;authentication_string:字段表示用户密码。