mysql5.7的密码修改错误问题:ERROR 1054 (42S22): Unknown column 'password' in 'field list'的解决

本意向修改一个用户的密码,网上搜到的命令为如下

1

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

执行后报错  ERROR 1054(42S22) Unknown column 'password' in ‘field list’

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

所以请使用一下命令:

E:\app\mysql\mysql-5.7.22-winx64\bin>mysql -uroot -pmysql123  # 先进入数据库
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.7.22 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use mysql;  # 使用mysql
Database changed
mysql> select User from user;  # 此处为查询用户命令
+---------------+
| User          |
+---------------+
| root          |
| root          |
| mysql.session |
| mysql.sys     |
| root          |
+---------------+
5 rows in set (0.01 sec)

mysql> update mysql.user set authentication_string=password('mysql') where user='root';  # 更新密码
Query OK, 3 rows affected, 1 warning (0.00 sec)
Rows matched: 3  Changed: 3  Warnings: 1

mysql> flush privileges;  # 数据刷新
Query OK, 0 rows affected (0.00 sec)

mysql> quit  # 退出
Bye

E:\app\mysql\mysql-5.7.22-winx64\bin>mysql -uroot -pmysql  # 再次进入
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.7.22 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

跟我这样设置,就可以了,大家自己设置自己的密码就行

猜你喜欢

转载自blog.csdn.net/weixin_43743725/article/details/84972464