Mariadb 10.5.x 和 Wordpress 的问题,这要归功于 "mysql.user" 现在成为一个视图

Mariadb 10.5.x and issues with Wordpress thanks to "mysql.user" being a view now

我刚刚发现了 MariaDB 最新版本的愚蠢新问题,其中包含 mysql.user 作为视图。我所有导入的 Wordpress 数据库突然无法从博客连接。当我什至尝试列出 mysql.user 时,它向我显示:

> select * from mysql.user; 
ERROR 1356 (HY000): View 'mysql.user' references invalid table(s)
or column(s) or function(s) or definer/invoker of view lack 
rights to use them

我们能做些什么来解决这个问题?

编辑:找到,但没有解决方案,只有建议。 ALTER USER 命令——在哪里使用以及使用什么设置?我是否必须以某种方式更改每个博客数据库的权限?

更新:

进一步调查发现,, and my initial response to it (below) may be related to an Incorrect definition of table mysql.event problem. In my case, I had 1) loaded a full dump (including the mysql database) from MySQL 5.7.33 to a fresh installation of MariaDB10.5.9; 2) discovered that this was not a good idea中描述的问题; 3) 编辑我的转储文件以排除 mysql 数据库,以及 4) 在不删除任何数据库或配置的情况下重复加载。

这导致数据库正常运行,但是(除了本问题中描述的问题)a) /usr/sbin/mariadbd --verbose --help 会尝试 运行 数据库服务器而不是打印帮助,b)启动时总是出现以下错误:

Apr 05 08:52:46 xxx mariadbd[22668]: 2021-04-05  8:52:46 0 [ERROR] Incorrect definition of table mysql.event: expected column 'sql_mode' at position 14 to have type set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','IGNORE_BAD_TABLE_OPTIONS','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE','NO_ENGINE_SUBSTITUTION','PAD_CHAR_TO_FULL_LENGTH','EMPTY_STRING_IS_NULL','SIMULTANEOUS_ASSIGNMENT'), found type set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','NOT_USED','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_B
Apr 05 08:52:46 xxx mariadbd[22668]: 2021-04-05  8:52:46 0 [ERROR] mariadbd: Event Scheduler: An error occurred when initializing system tables. Disabling the Event Scheduler

今天,我能够通过以下方式纠正这些问题(在 Amazon Linux 2 下):

  1. 正在卸载 MariaDB 服务器和 MariaDB 客户端
  2. 删除 /etc/my.*
  3. 删除/var/lib/mysql
  4. 正在重新安装 MariaDB 服务器和 MariaDB 客户端
  5. 重新加载数据库转储,再次省略 mysql 数据库的转储

在这一点上,我不仅有干净的数据库启动和 /usr/sbin/mariadbd --verbose --help 的正常运行,我还发现 select * from mysql.user 正常工作!

所以无法从 mysql.user select 的问题似乎不是由 [= 的变化引起的77=] 来自 table 以我原先的想法来查看,但是来自与我“不正确”的数据库迁移相关的其他一些问题。


我的初始答案:

(收录仅供参考)

经过大量研究,我至少找到了这个问题的部分答案:

tl;博士:select * from mysql.global_priv 然后对于每个用户, show grants for 'XXX'@'localhost';

更长的版本,来自 Authentication in MariaDB 10.4 — Understanding the Changes

The password storage has changed. All user accounts, passwords, and global privileges are now stored in a mysql.global_priv table. What happened to the mysql.user table? It still exists and has exactly the same set of columns as before, but it’s now a view over mysql.global_priv...."

上述文章不仅提供了什么,还提供了为什么。我并不完全同意。特别是声称 Old mysql.user table 仍然存在,你可以像以前一样从它 select ,但你不能(因此这个问题).尽管如此,我还是很欣慰地从 MariaDB 中发现了一个相对连贯的解释。

最后,举个例子:

MariaDB [(none)]> select * from mysql.global_priv\G
*************************** 1. row ***************************
Host: localhost
User: mariadb.sys
Priv: {"access":0,"plugin":"mysql_native_password","authentication_string":"","account_locked":true,"password_last_changed":0}
*************************** 2. row ***************************
Host: localhost
User: root
Priv: {"access": 1844674407370915, "plugin": "mysql_native_password", "authentication_string": "*9A87226E872127C756290C504DB5D9076E", "auth_or": [{}, {"plugin": "unix_socket"}], "password_last_changed": 1617303275}
*************************** 3. row ***************************
Host: localhost
User: mysql
Priv: {"access":1844674407371615,"plugin":"mysql_native_password","authentication_string":"invalid","auth_or":[{},{"plugin":"unix_socket"}]}
*************************** 4. row ***************************

MariaDB [(none)]> show grants for 'root'@'localhost'\G
*************************** 1. row ***************************
Grants for root@localhost: GRANT ALL PRIVILEGES ON *.* TO `root`@`localhost` IDENTIFIED VIA mysql_native_password USING '*9A87226E872127C756290C5BF177504DB5D9076E' OR unix_socket WITH GRANT OPTION
*************************** 2. row ***************************
Grants for root@localhost: GRANT PROXY ON ''@'%' TO 'root'@'localhost' WITH GRANT OPTION