mysql命令flush privileges命令


修改一个用户的密码,命令如下

mysql> update user set password=password('新密码') where user='用户名';

执行后报错:

ERROR 1054 (42S22): Unknown column 'password' in 'field list'

错误的原因是 5.7版本下的mysql数据库下已经没有password这个字段了,password字段改成了authentication_string

应使用如下命令:

mysql> update mysql.user set authentication_string=password('root') where user='root';
Query OK, 1 row affected, 1 warning (0.03 sec)
Rows matched: 1  Changed: 1  Warnings: 1

mysql> flush privileges;-  立即生效

mysql 新设置用户或更改密码后需用flush privileges刷新MySQL的系统权限相关表,否则会出现拒绝访问,还有一种方法,就是重新启动mysql服务器,来使新设置生效。-


转载:mysql命令flush privileges
https://blog.51cto.com/kuiba/777457