MariaDB 无法修改用户数据问题




项目场景:

安装调试MariaDB





问题描述:

在修改MariaDB中 mysql.user 表时,发生如下错误

View 'mysql.user' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them




原因分析:

根据SQL响应异常来看,第一反应应该是表/字段/方法异常或者是权限异常,但是检查了用户权限与数据库结构后,排除了这两个问题

细看之下,发现了这个提示:`of view lack rights to use them`,这里面提到了`view`也就是视图,是不是说明,mysql.user不是一张表?于是google之

MariaDB官方资料说,mysql.user从10.4版本开始,不再是一张表而是一个视图

In MariaDB 10.4 and later, the mysql.global_priv table has replaced the mysql.user table, and mysql.user should be considered obsolete. It is now a view into mysql.global_priv created for compatibility with older applications and monitoring scripts. New tools are supposed to use INFORMATION_SCHEMA tables. From MariaDB 10.4.13, the dedicated mariadb.sys user is created as the definer of the view. Previously, root was the definer, which resulted in privilege problems when this username was changed (MDEV-19650).

P.s 参考https://mariadb.com/kb/en/mysqluser-table/icon-default.png?t=LA92https://mariadb.com/kb/en/mysqluser-table/

并且提供了一个新表mysql.global_priv来替代mysql.user,而且提供了一个新的命令:ALERT USER,所以,解决方案就来了





解决方案:

1. 编辑mysql.global_priv表:

UPDATE mysql.global_priv SET Host='%' WHERE User='root';

2. 使用 `ALTER USER` 命令:

有待研究 

可参考资料:ALTER USER - MariaDB Knowledge BaseModify an existing MariaDB account.https://mariadb.com/kb/en/alter-user/

对了,别忘了刷新一下权限:

flush privileges;

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值