首页 > 解决方案 > MySQL 可以在任何场景下自动执行 Alter User 查询吗?

问题描述

我在 MySQL 中启用了 5 个节点的组复制,一切正常。

当我今天检查时,有 2 个节点出现问题,并且由于以下类似错误,两个节点都无法连接到组:

This member has more executed transactions than those present in the group. Local transactions: 648066b4-3642-476c-be1a-5a4b98248ee4:1-822137:1000009-1111095:2000379-2000583, b1cabb95-ed59-11eb-abb6-3c7c3f0f812c:1, f0d5216c-e46e-11eb-9d58-04d9f57da18c:1-76 > Group transactions: 648066b4-3642-476c-be1a-5a4b98248ee4:1-822137:1000009-1114518:2000379-2000583, f0d5216c-e46e-11eb-9d58-04d9f57da18c:1-76

以前我也经常遇到同样的错误。但是我曾经再次重新安装 mysql 并添加到组而不检查运行的查询。

今天,在阅读本文时,我发现以下查询在两个节点中都执行了,因为哪些节点有更多事务:

+---------------+-----+----------------+-----------+-------------+--------------------------------------------------------------------------------------+
| Log_name      | Pos | Event_type     | Server_id | End_log_pos | Info                                                                                 |
+---------------+-----+----------------+-----------+-------------+--------------------------------------------------------------------------------------+
| binlog.000012 |   4 | Format_desc    |         3 |         125 | Server ver: 8.0.26-0ubuntu0.20.04.2, Binlog ver: 4                                   |
| binlog.000012 | 125 | Previous_gtids |         3 |         224 | 648066b4-3642-476c-be1a-5a4b98248ee4:674241-822137:1101529-1111078:2000579-2000583   |
| binlog.000012 | 224 | Gtid           |         3 |         297 | SET @@SESSION.GTID_NEXT= '1234903d-ed59-11eb-8671-74d4352beb24:1'                    |
| binlog.000012 | 297 | Query          |         3 |         440 | use `mysql`; ALTER USER 'root'@'localhost' IDENTIFIED WITH 'auth_socket' /* xid=3 */ |
+---------------+-----+----------------+-----------+-------------+--------------------------------------------------------------------------------------+

由于这 5 个节点都是由我管理的多个家庭网络中的本地节点。

  1. 我的网络或服务器是否存在漏洞,导致其他人运行了 alter 命令?
  2. 还是这个命令是 MySQL 自动执行的?

目前mysql_secure_installation没有在任何节点执行,因此mysqlroot用户无需密码即可直接访问。

在这种情况下我应该怎么做?

标签: mysqldatabase

解决方案


推荐阅读