解决Linux(CentOS) MySQL修改密码:ERROR 1133 (42000): Can't find any matching row in the user table

set password for root@localhost=password('你的密码'); 

报错

mysql> set password for root@localhost = password('Su#2021Gjj');
ERROR 1133 (42000): Can't find any matching row in the user table

解决
代码中的localhost修改%,与数据库Host字段值一致

select Host,User from user;
set password for 'root'@'%'=password('Su#2021Gjj');
flush privileges;

mysql> select Host,User from user;
+-----------+---------------+
| Host      | User          |
+-----------+---------------+
| %         | root          |
| localhost | mysql.session |
| localhost | mysql.sys     |
+-----------+---------------+
3 rows in set (0.00 sec)
mysql> set password for 'root'@'%'=password('Su#2021Gjj');
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

你可能感兴趣的:(解决Linux(CentOS) MySQL修改密码:ERROR 1133 (42000): Can't find any matching row in the user table)