mysql5.6以上版本修改密码

安装好mysql后修改root用户的密码,网上搜到的命令为如下

mysql> update user set password = '****' where User = '****';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to you

执行后报错  ERROR 1054(42S22) Unknown column ‘password’ in ‘field list’
错误的原因是 5.7版本以上的mysql数据库下已经没有password这个字段了,password字段改成了authentication_string。
在这里插入图片描述

mysql> select User from user;
+------------------+
| User             |
+------------------+
| mysql.infoschema |
| mysql.session    |
| mysql.sys        |
| root             |
+------------------+
4 rows in set (0.00 sec)
mysql> update mysql.user set authentication_string='****' where user='root';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 0
mysql> flush privileges;  //立即生效
Query OK, 0 rows affected (0.00 sec)

你可能感兴趣的:(mysql5.6以上版本修改密码)